繁体   English   中英

在Cordova Android上无法让pushwoosh接收通知

[英]Can't get pushwoosh to receive notifs on Cordova Android

由于某些原因,我不明白,我在Android设备上未收到PN。

我确实在console.firebase.google.com配置了GCM。

我确实将生成的google-services.json文件放在了cordova项目的platform/android文件夹中。

我当然安装了cordova pushwoosh-phonegap-plugin插件。

我在应用程序的引导程序中添加并调用了以下代码:

function initPushwoosh(store) {
    var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");

    // Should be called before pushwoosh.onDeviceReady
    document.addEventListener('push-notification', function(event) {
        console.log('RECEIVED PN: ',event);
    });

    // Initialize Pushwoosh. This will trigger all pending push notifications on start.
    pushwoosh.onDeviceReady({
        appid: "...",
        projectid: "..."
    });

    if (myApp.pnToken == null) {
        pushwoosh.registerDevice(
            function(status) {
                var pushToken = status.pushToken;
                console.log('received token',pushToken);
            },
            function(status) {
                console.error(status);
            }
        );
    }
    else {
        pushwoosh.getPushwooshHWID(function(pwid){console.log('PUSHWOOSH ID: ',pwid);});
    }
}

在运行时,我看到我的应用程序成功订阅了PUSHWOOSH(我收到一个pw令牌,并具有一个pw客户端ID),并且在Pushwoosh管理界面中看到了我在Android“用户”中唯一的测试Android设备。

但是,当我从PW管理界面发送示例通知时,永远不会触发“推送通知”事件...

以下是部分logcat的更多信息:

    01-17 11:26:57.144 9254-9653/my.app D/Pushwoosh: [CordovaPlugin] Plugin Method Called: onDeviceReady
    01-17 11:26:57.145 9254-9653/my.app I/Pushwoosh: [NotificationManager] App ID: XXXXX-XXXXX
    01-17 11:26:57.147 9254-9653/my.app I/Pushwoosh: [NotificationManager] Sender ID: XXXXXXXXXX
    01-17 11:26:57.149 9254-9254/my.app D/Pushwoosh: onAppReady
        sendAppOpenEndTagMigrate
    01-17 11:26:57.154 9254-9653/my.app D/Pushwoosh: [CordovaPlugin] Plugin Method Called: getPushwooshHWID
    01-17 11:26:57.160 9254-9254/my.app D/Pushwoosh: [[BusinessCase]] trigger welcome-inapp
        [BusinessCase] welcome-inapp condition not satisfied
        [[BusinessCase]] trigger app-update-message
    01-17 11:26:57.161 9254-9254/my.app D/Pushwoosh: [BusinessCase] app-update-message condition not satisfied
    01-17 11:26:57.172 9254-9254/my.app D/Pushwoosh: [JobServiceEngineImpl] onStartJob: android.app.job.JobParameters@344323
    01-17 11:26:57.183 9254-18165/my.app D/Pushwoosh: [RequestManager] Try To send: applicationOpen; baseUrl: https://DB224-ABAD6.api.pushwoosh.com/json/1.3/

    01-17 11:26:57.588 9254-18165/my.app I/Pushwoosh: [RequestManager] 
        x
        |     Pushwoosh request:
        | Url: https://xxxxx.api.pushwoosh.com/json/1.3/applicationOpen
        | Payload: {"request":{"application":"XXXXXX","hwid":"xxxxxx","v":"5.11.0","device_type":3,"userId":"xxxxx","device_name":"Phone","language":"fr","timezone":3600,"android_package":"my.app","jailbroken":1,"device_model":"Samsung SM-G950F","os_version":"8.0.0","app_version":"1.3.4","notificationTypes":6}}
        | Response: {"status_code":200,"status_message":"OK","response":{"required_inapps":[]}}
        x

有什么事吗

几个问题: platform/android是否适合google-services.json文件? -其他问题:cordova插件是否需要这些步骤 -Firebase SDK配置的最后一步(显然是可选的)没有结束:

在此处输入图片说明

有什么后果吗?

好的,我有两个问题:首先,我应该使用“旧”类型的FCM服务器密钥,而我应该使用新的。 其次,我希望通过监听'push-notification'事件在应用程序处于前台时收到推送通知。 我应该听的'receive-push'事件,而不是...这样做解决了我与实际接收(和他们的宝贵的通知具有麻烦userdata在我的JS代码)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM