I am struggling with FCM notifications on Android. The issue is only when the app is closed and not running. I am trying to achieve no click activity I don\'t want the app
FCM displays my notification the way it wants to when the app is closed. That's ok with me. I just want to make sure the entire notification gets read and not lost. Here is my solution... When an app user clicks on the notification it opens the app and displays the notification in an alert Dialog.
c# server-side code to send the message
var msg2send = new
{
to = deviceId,
priority = 10,
notification = new
{
body = msg,
title = "Red Hill Car Wash",
icon = "myicon"
},
data = new
{
notice = msg
}
};
And in the onCreate of MainActivity
String notice = "";
try {
notice = getIntent().getStringExtra("notice");
if (notice != null)
{
Log.i("myStuff", notice);
///// DISPLAY NOTIFICATION IN AN ALERT DIAGLOG all good!
}
}
catch (Exception ex) {
Log.i("myStuff", ex.getMessage());
}
FCM passes the message to my MainActivity, if a message exists then I grab it and can display it how ever I want. Thank for the comments and input to help solve this issue.