ios Google Cloud Messaging (GCM) not receiving remote notifications

放肆的年华 提交于 2019-11-29 13:10:08

The error 2001 you get is NOT kGGLInstanceIDOperationErrorCodeMissingKeyPair but rather kGCMServiceErrorCodeAlreadyConnected. The latter means that you're already connected to GCM. To better debug this I would try to send a display notification to the device token i.e. send this

$post_json_encode = '{"notification":{"body":"' . $msg . '"},"to":"/topics/global"}';

You should theoretically connect to GCM when your app is in the foreground and disconnect when you go to background. You can then reconnect again when you come to the foreground.

The data payload and notification payload are both applicable on iOS & Android. On iOS the difference is that notification payload is sent through APNS while data payload is sent through GCM's own connection which is only there when app is in foreground. In Android notification payload is the new display notification stuff added recently.

I was facing the same issue on iOS. Then I found the solution on PushBots website. It is working fine for me now.

In XCode go to Targets > Build settings > Code Signing Identity and make sure it's not automatic and set to the profile matching certificate linked to the application ID for example

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