【发布时间】:2019-01-17 11:44:33
【问题描述】:
由于某种我不明白的原因,我的 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 管理界面发送示例通知时,从未触发“推送通知”事件...
以下是部分日志猫的更多信息:
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 插件是否需要those steps 中的任何一个?
- Firebase SDK 配置的最后一步(显然是可选的)没有结束:
这会有什么后果吗?
【问题讨论】:
标签: android cordova firebase-cloud-messaging pushwoosh