DEV Community

Discussion on: how to send push notification to particular user using fcm (firebase Messaging) and Flutter

 
zeeshanmehdi profile image
zeeshan mehdi

this error means you are being sent an empty response. there is something that you are missing in the request.
please ensure these points
checklist

  • header
  • token ( of receivers device)
  • fcm send url is valid
  • body is in the json format
Thread Thread
 
roshdialmajzoub profile image
roshdiAlMajzoub

Now i am getting on the terminal that fcm request for device sent but i am not getting any notificstion

Thread Thread
 
zeeshanmehdi profile image
zeeshan mehdi

configure receiving end well. there might be issues on receiving end now

Thread Thread
 
roshdialmajzoub profile image
roshdiAlMajzoub

How can i solve it?

Thread Thread
 
zeeshanmehdi profile image
zeeshan mehdi

logout and relogin on receiving device, make sure token is same and valid. in console you can print out if it is inside onlaunch ,onMessage or onResume if one of these methods is getting triggered on receiver app that means something is wrong with your implementation

Thread Thread
 
zeeshanmehdi profile image
zeeshan mehdi

share a screenshot of your console

Thread Thread
 
roshdialmajzoub profile image
roshdiAlMajzoub

Can you show me a sample code about it?

Thread Thread
 
zeeshanmehdi profile image
zeeshan mehdi

_fcm.configure(
onMessage: (Map message) async {
print("onMessage: $message");
showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: [
FlatButton(
child: Text('Ok'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
onLaunch: (Map message) async {
print("onLaunch: $message");
// TODO optional
},
onResume: (Map message) async {
print("onResume: $message");
// TODO optional
},
);

Thread Thread
 
roshdialmajzoub profile image
roshdiAlMajzoub

Where i put these stuff?!!

Thread Thread
 
zeeshanmehdi profile image
zeeshan mehdi

in your home page initstate method