Google push notification not working in production

女生的网名这么多〃 提交于 2019-12-08 13:59:54

问题


I am getting this error on IOS google push notification

The operation couldn’t be completed. (com.google.gcm error 501.)

I get the registration id in development environment and production environment.

The message of development enviornment:

{"multicast_id":8145067860904395870,"success":1,"failure":0,"canonical_ids":0,"results":
[{"message_id":"0:1452842547360715%bc92eed1bc92eed1"}]}

and I successfully receive the message.

But in production environment I get this message.

{"multicast_id":8861850059359760561,"success":0,"failure":1,"canonical_ids":0,"results":
[{"error":"NotRegistered"}]}

and no notification is received.

I have tried every thing from revoking certificate and creating new certificate and new provisioning profile to cleaning build folder but notification is still not working in production.


回答1:


The solution for me is that i have to go to AppDelegate.swift file and search for kGGLInstanceIDAPNSServerTypeSandboxOption in development it should be true and for production it should be false. Just changed it to false for production and notification was working for me.




回答2:


You can do it like this for production environment.:

GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig)
    registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken,
                           kGGLInstanceIDAPNSServerTypeSandboxOption:false]
    GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID,
                                                             scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)


来源:https://stackoverflow.com/questions/34806142/google-push-notification-not-working-in-production

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