无法在Lollipop中看到背景中的通知

时间:2018-03-14 07:15:13

标签: android firebase-cloud-messaging android-notifications

我正面临一个问题,即我在Android 5关闭应用程序(杀死)时没有收到通知。通知即将发布在我的其他设备上,即android 7

我这样做:

public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.d("in On MessageReceived","true");
        remoteMessage.getData().get("body"));
        addNotification(remoteMessage.getData().get("body"), remoteMessage.getData().get("Nick"));
    }

当我打印日志消息时,它没有打印出来。所以我的onMessageReceived没有被调用。

当我在网上进行一些研究时,我发现我应该使用HandelIntent。我也尝试过但结果相同

片刻我在应用程序关闭时发送通知我的Logcat显示这些消息

03-14 12:42:09.138 22931-22931/? I/ServiceManager: Waiting for service AtCmdFwd...
03-14 12:42:10.139 22931-22931/? W/Atfwd_Sendcmd: AtCmdFwd service not published, waiting... retryCnt : 3
03-14 12:42:13.463 2705-2705/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=com.thb.android.thunderBolt (has extras) }
03-14 12:42:14.454 1206-1238/? I/ActivityManager: Start proc com.android.thememanager for service com.android.thememanager/.service.ThemeTaskService: pid=25007 uid=9801 gids={49801, 9997, 2001, 3003, 1028, 1015, 1023} abi=armeabi-v7a
03-14 12:42:14.524 1206-1238/? V/LocationPolicy: onProcessStateChanged
03-14 12:42:14.534 25007-25007/? W/ResourcesManager: Asset path '/system/framework/cloud-common.jar' does not exist or contains no resources.
03-14 12:42:14.694 3388-3433/? I/XiaomiFirewall: firewall pkgName:com.android.thememanager, result:0

这也是在logcat中

03-14 14:52:37.071 5222-5222/? I/ServiceManager: Waiting for service AtCmdFwd...
03-14 14:52:38.072 5222-5222/? I/ServiceManager: Waiting for service AtCmdFwd...
03-14 14:52:39.063 5222-5222/? I/ServiceManager: Waiting for service AtCmdFwd...
03-14 14:52:40.064 5222-5222/? I/ServiceManager: Waiting for service AtCmdFwd...
03-14 14:52:41.065 5222-5222/? I/ServiceManager: Waiting for service AtCmdFwd...

在后端(nodeJS)中,我的代码是

notification = function (arr, message, nick) {
    var message = {
        registration_ids: arr,
        data: {
            Nick: nick,
            body: message
        }
    };
    fcm.send(message, function (err, response) {
        if (err) {
            console.log(err)

        } else {
            console.log("Successfully sent with response: ", response)
        }
    })
}

有人可以帮我解决这个问题。或者我做错了什么。它很奇怪,因为它在1个设备上而不是在另一个设备上工作。

0 个答案:

没有答案