Phonegap: GCM Push Notification registration call returns OK but device is not even connected to the internet

跟風遠走 提交于 2019-12-02 03:03:11
  1. register

    When you call pushNotification.register():

    • successHandler is called if there is no error in parsing your ecb and senderID. Your senderID and application are registered with GCMRegistrar.
    • errorHandler is called only if there is a JSON error while parsing the ecb or senderID

    Once your setup is correct, your errorHandler will probably never be called.

    From the docs, you have to call the register method every time you start the application. This will not create duplicate registrations. The plugin will manage all that itself.

  2. onNotificationGCM

    Only called when:

    • You receive a notification from GCM.
    • Your application is successfully registered with GCMRegistrar
  3. GCMRegistrar

    • Returns registration ID (for your application and senderID) if already registered.
    • If not, it registers your application and senderID and then returns registration ID. This requires an Internet connection (AFAIK)

    So when you call pushNotification.register the first time, if you are not connected to the Internet, PushPlugin returns OK but GCMRegistrar has no registration ID to return to you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!