且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IOS谷歌云消息(GCM)不接收远程通知

更新时间:2022-11-22 22:47:45

您得到的错误2001年不是 kGGLInstanceIDOperationError codeMissingKeyPair 而是 kGCMServiceError codeAlreadyConnected 。后者意味着你已经连接到GCM。为了更好地调试这个我会尝试显示通知发送到设备令牌即发送此

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_en code ='{通知:{体:'。$味精。
  },要:/主题/全球}';

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

您理论上应该连接到GCM当你的应用程序是在前台,当你去后台断开连接。当你来到前台,您可以然后再重新连接。

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.

数据有效载荷的通知有效载荷均适用于iOS和放大器; Android系统。在iOS不同的是,通知的有效载荷通过APNS发送在数据负载是通过GCM自己的连接,也就是只有在那里,当应用程序在前台发送。在Android的通知有效载荷是最近添加新的显示通知的东西。

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.