I defined firebase service:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
public void onMessageReceived(com.google.firebase.messaging.RemoteMessage remoteMessage) {
mgr.showNotification("X:" + remoteMessage.getNotification().getTitle(), "X:" + remoteMessage.getNotification().getBody(), data);
}
@Override
public void onDeletedMessages() {}
@Override
public void onMessageSent(java.lang.String s) {}
@Override
public void onSendError(java.lang.String s, java.lang.Exception e) {}
}
And android manifest:
<service
android:name=".integration.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
There are two very strange behaviours with the FCM I noticed:
Sometimes onMessageReceived() is called and sometimes not. It depends on whether my app is running or not. Anyway the notification is still displayed (that's why I added "X:")
Sometimes there is no notification and no onMessageReceived is called at all, but I can see in "FCM diagnostics" in developer console that message was acknowledged:
Current Status Acknowledged Collapse Key <key> TTL 2,419,200 TIME CURRENT STATUS 20 Jun 17:35 Device connected 20 Jun 21:23 Accepted 20 Jun 21:23 Delivered 20 Jun 21:28 Acknowledged
Can anybody explain this?