谷歌云消息仅在应用升级时崩溃

时间:2015-09-30 21:13:40

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

我面临着一个针对iOS的Google云消息传递的奇怪问题。 调用

后,该应用程序崩溃了几秒钟

[[GGLContext sharedInstance] configureWithError:&configureError];

只有在已安装从应用商店下载的应用的较旧版本时,Xcode才会安装带有Google/CloudMessaging SDK的新应用。

但是,如果我在全新安装上运行它,一切都很顺利。

崩溃的原因是什么?以及如何解决?

// From Google GCM Sample app
// https://github.com/googlesamples/google-services/blob/master/ios/gcm/GcmExample/AppDelegate.m
- (void)configureGCM {
    NSLog(@"Start ConfigureGCM");
    NSError* configureError;
    [[GGLContext sharedInstance] configureWithError:&configureError];
    NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
    _gcmSenderID = [[[GGLContext sharedInstance] configuration] gcmSenderID];
    NSLog(@"gcmSenderID : %@, ConfigureError: %@", _gcmSenderID, configureError);
    GCMConfig *gcmConfig = [GCMConfig defaultConfig];
    gcmConfig.receiverDelegate = self;
    [[GCMService sharedInstance] startWithConfig:gcmConfig];

    __weak typeof(self) weakSelf = self;

    _gcmRegistrationHandler = ^(NSString *registrationToken, NSError *error){
        if (registrationToken != nil) {
            NSLog(@"GCM Registration Token: %@", registrationToken);
            if(![weakSelf.user hasSyncedGCMToken]) {
                [weakSelf.user syncGCMTokenWithServer:registrationToken];
            }
        } else {
            NSLog(@"Registration to GCM failed with error: %@", error.localizedDescription);
        }
    };
    NSLog(@"End ConfigureGCM");
}

以下是日志:

] Start ConfigureGCM
] Successfully configured [CloudMessaging].
] Failed to configure [].
] Subspecs not present, so not configured [Analytics, AdMob, SignIn, AppInvite, Maps].
] Subspecs expected to be present [CloudMessaging, Measurement].
] <GMR/INFO> App measurement v.1100000 started
] <GMR/ERROR> Exception on worker queue: data parameter is nil
] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
 *** First throw call stack:
(0x30cb3e83 0x3b0106c7 0x30cb3dc5 0x315f127f 0x122b73 0x1222ad 0x123bcb 0x129d9f 0x3b4f50c3 0x3b4f9e7b 0x3b4f6f93 0x3b4fa745 0x3b4fa9c5 0x3b624dff 0x3b624cc4)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是stacktrace的截图 enter image description here

enter image description here

更新

iOS8或更高版本似乎没有发生此问题。 对我来说,崩溃是在iPhone 5上使用iOS 7.0.4

更新-2

目前,我仅针对iOS 8+用户使用推送通知。仍在等待Google的回复on Github

更新-3

已在最新版本的GCM中修复

1 个答案:

答案 0 :(得分:0)

更新

此问题已由GCM <{3}}