【发布时间】:2017-01-30 02:19:39
【问题描述】:
我正在编写一个 Ionic 应用程序并尝试使推送通知工作。
我正在使用phonegap-plugin-push 插件来执行此操作。
在“$ionicPlatform.ready”事件中,我获得了设备令牌
var push = PushNotification.init({
android: {
senderID: "36112019308"
}
});
push.on('registration', function(data) {
window.localStorage.setItem('tkn', data.registrationId );
});
好吧,我在这里得到了注册 ID。现在,当我尝试按照here 描述的步骤操作时,使用如下所示的 curl 命令
curl --header "Authorization: key={KEY_GOT_ON_GOOGLE_CONSOLE}" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"THE_REGISTRATION_ID_GOT_ON_DEVICE"]}"
我得到错误:
{"multicast_id":4787366485826638756,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
好吧,我确信密钥和注册 ID 是正确的,因为如果我更改密钥,我会收到 unauthorized 错误,如果我更改注册 ID,我会收到 InvalidRegistration 错误
我做错了什么?
附加信息
- 使用调试版本进行测试
【问题讨论】:
-
你看过这篇文章了吗:stackoverflow.com/a/36492797/2549619 ?
标签: android cordova ionic-framework push-notification