I am trying to implement firebase push notifications for a flutter app.
But it appears just as an icon in the status bar. How can i make it pop up?
I want popup on the screen when notification is received.
Here is how my code looks like:
Future<bool> sendNotification(var userToken, String bodyMessage) async {
final data = {
"notification": {
"body": bodyMessage,
"title": "Leave Application",
},
"priority": "high",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"id": "1",
"status": "done"
},
"registration_ids": userToken,
};
final headers = {
'content-type': 'application/json',
'Authorization':
'key=<Firebase web key>',
};
final response = await http.post(postUrl,
body: json.encode(data),
encoding: Encoding.getByName('utf-8'),
headers: headers);
if (response.statusCode == 200) {
print(response.statusCode.toString());
print("Working");
return true;
} else {
print(postUrl.toString());
print(response.statusCode.toString());
print("Not Working");
return false;
}
}