unable to register (com.google.iid error 1005.)

1.9k views Asked by At

I'm attempting to integrate GCM into our iOS app. I've followed the instructions to update our project for GCM to no avail. Everything I try to register I get:

Registration to GCM failed with error: The operation couldn’t be completed. (com.google.iid error 1005.)

Which GLLInstance.h say:

  /// Should call `startWithConfig:` before requesting token.
  kGGLInstanceIDOperationErrorCodeInvalidStart = 1005,

I am calling :

[[GCMService sharedInstance] startWithConfig:[GCMConfig defaultConfig]];

before registering for notifications... There aren't any obvious errors from GCM This IS on a device... (just trying to eliminate the obvious)

What next steps should I try?

1

There are 1 answers

2
morgman On

As usual as soon as I post a question to SO, the answer leaps out at me.

The routine:

[[GCMService sharedInstance] startWithConfig:[GCMConfig defaultConfig]];

which I knew I was calling in:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

right before

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];

was needed in two locations... I missed that. Once I added it just before the call:

[[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:_gcmSenderID
                                                    scope:kGGLInstanceIDScopeGCM
                                                  options:_registrationOptions
                                                  handler:_registrationHandler];

in:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

everything started working. Delightful...