FCM Push Notification not working when app close in some of the devices like xiaomi, oppo, vivo,Redmi and some of OS (Oxygen OS, Color OS, MIUI etc).
But other devices and OS working good.
Does anyone have experience about it?
Android end code.
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
/**
* Called when message is received.
*
* @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
*/
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
}
}
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = MyFirebaseInstanceIDService.class.getName();
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
}
private void sendRegistrationToServer(String refreshedToken) {
}
}
<service
android:name=".MyFirebaseInstanceIDService"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyFirebaseMessagingService"
android:stopWithTask="false"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Sever End Code
{
"notification": {
"title": "FCM Kazi",
"body": "FCM bdoy1 ",
"sound": "default",
"click_action": "FCM_PLUGIN_ACTIVITY",
"icon": "fcm_push_icon"
},
"data": {
"param1": "value1",
"param2": "value2"
},
"to": "cVL4I6upF-g:APA91bE7EFv3apIMHuEL_oCoVvhhrUw-ftM6S11RE9HOF58wf3ewYkDUh9wUhUCMIa6zoftOgGH5HWt0rPKVHw2OShn06tIESFnGo9u8rooJ9qfiXQQlg-zZzjgi0cQ64BUaZnUCM09R",
"priority": "high"
}