在某些设备(如小米oppo,vivo,Redmi和某些操作系统(氧气操作系统,彩色操作系统,MIUI等)中关闭应用程序时,FCM推送通知不起作用

时间:2018-10-10 09:20:21

标签: android firebase firebase-cloud-messaging

在某些设备(如小米,oppo,vivo,Redmi和某些操作系统(氧气操作系统,彩色操作系统,MIUI等))中关闭应用程序时,FCM推送通知不起作用。

但是其他设备和操作系统运行良好。

有人有经验吗?

Android结束代码。

公共类MyFirebaseMessagingService扩展了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());


}

}

公共类MyFirebaseInstanceIDService扩展了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>

服务器结束代码

{
"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"
}

1 个答案:

答案 0 :(得分:-1)

仅使用数据播放量,并删除通知播放量。数据播放量总是会收到应用程序打开或关闭的问题。通知播放负载仅在应用处于前台状态时有效。而且,如果您没有在几个设备上接收信息,请转到设备设置并启用该应用程序的接收通知。默认情况下,很少有制造商不允许通知。