简体   繁体   English

注册推送通知会在Android上导致“无效操作”错误

[英]Registering to push notifications results in an “Invalid Action” error on Android

I'm trying to use PhoneGap's push notification plugin, but receive and error when trying to register for push notifications on Android (haven't tested on other platforms). 我正在尝试使用PhoneGap的推送通知插件,但是尝试在Android上注册推送通知时却收到错误消息(尚未在其他平台上进行测试)。 For testing purposes I created a minimal sample app that reproduces this problem. 为了进行测试,我创建了一个最小的示例应用程序来重现此问题。

Install sample app 安装示例应用

View sample app source code 查看示例应用程序源代码

Your help is greatly appriciated :-) 您的帮助非常有用:-)

I found the problem. 我发现了问题。 I wasn't using the plugin as I should have; 我没有使用应有的插件; instead of writing this: 而不是这样写:

pushNotification.register(pg_success_handler, pg_error_handler, {
  "senderID": "<sender id>",
  "ecb": on_pg_gcm_notification
});

I should have written this: 我应该这样写:

pushNotification.register(pg_success_handler, pg_error_handler, {
  "senderID": "<sender id>",
  "ecb": "on_pg_gcm_notification"
});

The registration works now :) 现在可以进行注册了:)

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

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