Manan Devani Manan Devani - 1 year ago 155
iOS Question

GCM : Configuring subspecs failed @ CloudMessaging

I am trying to integrate Google Cloud Messaging in my iOS application. I have followed every instruction provided in this link.

I have also integrated Google sign-in and it works fine.

The problem is I am getting assertion failure in the below code.

NSError* configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

Which is used to configure subspecs for cloud messaging.
This code above is in
method in

The error generated is:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error configuring Google services: Error Code=-104 "Unable to correctly configure subspec CloudMessaging" UserInfo={NSLocalizedDescription=Unable to correctly configure subspec CloudMessaging, NSLocalizedFailureReason=GCM Sender ID must not be nil or empty.

Now I don't understand the meaning of this error. Yes, it clearly states that sender ID must not be nil. But from where it gets null ID.

I have tested this in simulator. I don't know if that affects or not.

If I comment this code and run in real device I also get the registration token but I don't receive any notification from my server. Server side code is tested and works fine for android.

Answer Source

Finally I solved the problem. First of all thank you all for quick reply. What I did is explained in the following steps.

  1. Get GCMExample project. Which I downloaded from Github because pod try google does not list GCMExample project.
  2. Generate GoogleServices-Info.plist file from here

  3. Compare plist files of GCMExample and MyProject.

Here I got the difference in it. In My project GCM was disabled and there was no Sender ID in it. I don't know how the hell did that happened. So I manually set the GCM service enabled and added sender ID of my app that I previously created.

That is how I solved my problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download