iOS Gcm Error Code 501

iOS GCM error code 501

The error occurred because I was calling

GCMService.sharedInstance().connectWithHandler() { error in  if(error != nil) {   print(error) } } 

before I had received a registration token, or had failed to refresh my token.

"Error Domain=com.google.gcm Code=501 "(null)" " is a really bad error message.

ios Google Cloud Messaging (GCM) not receiving remote notifications

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.



Related Topics



Leave a reply



Submit