来自GCM iOS的注册令牌出错

时间:2015-11-11 18:54:47

标签: ios objective-c google-cloud-messaging

注册令牌始终为零并显示此错误:无法完成操作。 (com.google.iid错误0。)

AppDelegate.m

GGLInstanceIDConfig *instanceIDConfig = [GGLInstanceIDConfig defaultConfig];
instanceIDConfig.delegate = self;
[[GGLInstanceID sharedInstance] startWithConfig:instanceIDConfig];

registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken,
                         kGGLInstanceIDAPNSServerTypeSandboxOption:@YES};
[[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:@"mySenderID"
                                                          scope:kGGLInstanceIDScopeGCM
                                                  options:registrationOptions
                                                  handler:registrationHandler];

 registrationHandler = ^(NSString *registrationToken, NSError *error){

    if (registrationToken != nil) {

        myRegistrationToken = registrationToken;

        NSLog(@"Registration Token: %@", registrationToken);

        NSDictionary *userInfo = @{@"registrationToken":registrationToken};

    } else {

        NSLog(@"Registration to GCM failed with error: %@",    error.localizedDescription);
    }
};

0 个答案:

没有答案