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
Xcode 8.3 Swift Version Error (Swift_Version) in Objective C Project
Error | [Ios] File Patterns: the 'Source_Files' Pattern Did Not Match Any File
Problems with Layout of Some Rows in Swiftui List
Load Custom Error HTMLstring When Wkwebview Loadrequest Fails
Is Calling Cellforrowatindexpath: Ever Practical
Uiactivityviewcontroller => Launchservices: Invalidationhandler Called
Ionic 3 Response with Status: 0 for Url: Null
"Reached the Max Number of Texture Atlases, Can Not Allocate More" Using Google Maps
Determine The Maximum Number of Characters a UIlabel Can Take
How to Keep Animated Gifs Animated While Scrolling on iOS Devices
Map Object into 2D Array Swift for Tableview Sections
iOS Framework Does Not Work on Simulator
Can't Pan Image Taken from Camera with Uiimagepicker
iOS - Combine/Concatenate Multiple Audio Files
Can't Write Non Current User Objects by Pfuser Currentuser
Can't Use @Observedobject on Real iPhone
iOS Getting My Location Regularly and Setting Button to Get My Location - Google Map Not Working