You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read many posts about receiving data-messages in background mainly on Stackoverflow and we can find as many post to tell it works as to tell it doesn't work!
And the doc is really fuzzy about this specific feature and as Stackoverflow is fuzzy as well, I ask here expecting a definitive answer.
About the doc, where is the ability to receive data-payload message in background explained?
I can see explanation about notification, notification+data, but even if I see few data only examples, I cannot see anywhere what are for and if they are received in background. But there were for sure! Is it still the case? Mistery.
My problem is that I build an application quite recently with studio 1.5.2, corresponding sdk version !?!, FCM 9.2.0 which perfectly receives data messages like below The message is sent via Advanced REST client. This message is successfully sent of course.
But after I update studio to 2.1.2, sdk, and java (1.7 to 1.8), The same working project newly rebuilt is not able to receive any data message in background anymore.
And MyFirebaseMessagingService. I use a data payload message to create a custom notification, between others because I also process other type of payload messages.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public static final int NOTIFICATION_ID = 1;
private static final String TAG = "MyFirebaseMsgService";
/**
* Called when message is received.
*
* @param fcmMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage fcmMessage) {
Log.i(Constants.APP_TAG, "Received message " + fcmMessage.getData());
Map data = fcmMessage.getData();
Spanned span = null;
String id;
String title;
String message;
String webSite;
String image;
String location;
String latitude;
String longitude;
String startDate;
String endDate;
String publishEndDate;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = sharedPreferences.edit();
int code = Integer.parseInt((String) data.get("code"));
switch (code) {
case 2: // Notification
id = (String) data.get("id");
title = (String) data.get("title");
message = (String) data.get("msg");
webSite = (String) data.get("infosUrl");
location = (String) data.get("eventLocation");
latitude = (String) data.get("latitude");
longitude = (String) data.get("longitude");
startDate = (String) data.get("startDate");
endDate = (String) data.get("endDate");
if (title != null) {
span = Html.fromHtml(title);
title = span.toString();
}
if (message != null) {
span = Html.fromHtml(message);
message = span.toString();
}
if (location != null) {
span = Html.fromHtml(location);
location = span.toString();
}
if (webSite != null) {
span = Html.fromHtml(webSite);
webSite = span.toString();
}
Log.i(Constants.APP_TAG,
"\ntitle = " + title +
"\n message = " + message +
"\n code = " + code +
"\n location = " + location +
"\n latitude = " + latitude +
"\n longitude = " + longitude +
"\n website = " + webSite +
"\n start date = " + startDate +
"\n end date = " + endDate);
sendNotification(title, message, location, latitude, longitude, webSite, startDate, endDate);
break;
default:
break;
}
// [END_EXCLUDE]
}
// [END receive_message]
}
When I put my application in background, I receive D/FirebaseApp: Notifying background state change listeners. What does it mean?
Another strange behavior. In my working application, if I receive the message in foreground which generates the notification, when I put the application in background, the notification stays in the notification center. With the newly built project, when I put the application in background, the notification is automatically removed. I don't know if that can explain somthing.
So aredata payload messages really supposed to be received in background?
If no, why do I have a working application ??
If yes, what is missing in my setting to explain it doesn't work?
And could you enlighten a bit the feature in the doc?
EDIT
I also tried your quickstart-android messaging app and it doesn't receive anything when in background.
Is there any mistake in the sent message??
The text was updated successfully, but these errors were encountered:
Describe the problem:
I read many posts about receiving data-messages in background mainly on Stackoverflow and we can find as many post to tell it works as to tell it doesn't work!
And the doc is really fuzzy about this specific feature and as Stackoverflow is fuzzy as well, I ask here expecting a definitive answer.
About the doc, where is the ability to receive data-payload message in background explained?
I can see explanation about notification, notification+data, but even if I see few data only examples, I cannot see anywhere what are for and if they are received in background. But there were for sure! Is it still the case? Mistery.
My problem is that I build an application quite recently with studio 1.5.2, corresponding sdk version !?!, FCM 9.2.0 which perfectly receives data messages like below The message is sent via Advanced REST client. This message is successfully sent of course.
But after I update studio to 2.1.2, sdk, and java (1.7 to 1.8), The same working project newly rebuilt is not able to receive any data message in background anymore.
My manifest is:
And MyFirebaseMessagingService. I use a data payload message to create a custom notification, between others because I also process other type of payload messages.
When I put my application in background, I receive
D/FirebaseApp: Notifying background state change listeners.
What does it mean?Another strange behavior. In my working application, if I receive the message in foreground which generates the notification, when I put the application in background, the notification stays in the notification center. With the newly built project, when I put the application in background, the notification is automatically removed. I don't know if that can explain somthing.
So aredata payload messages really supposed to be received in background?
If no, why do I have a working application ??
If yes, what is missing in my setting to explain it doesn't work?
And could you enlighten a bit the feature in the doc?
EDIT
I also tried your quickstart-android messaging app and it doesn't receive anything when in background.
Is there any mistake in the sent message??
The text was updated successfully, but these errors were encountered: