1

我正在嘗試將GCM v3集成到cocos2d-x v3.6項目中,並且在使用CocoaPods和Xcode工作了幾天後,我終於能夠構建該應用程序。但是,在部署在設備上進行測試時,它會在調用[[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:_gcmSenderID scope:kGGLInstanceIDScopeGCM options:_registrationOptions handler:_registrationHandler]時崩潰,並顯示錯誤EXC_BAD_ACCESS。是什麼賦予了?EXC_BAD_ACCESS with GCM 3.0

截圖:http://i.imgur.com/s0HnxTp.png

我的配置如下:

daffodilistic$ pod --version 0.39.0.beta.4 daffodilistic$ cat Podfile platform :ios, '8.1' source 'https://github.com/CocoaPods/Specs.git' target 'project-redacted iOS' do pod 'Google/CloudMessaging' end target 'project-redacted Mac' do end

+0

這裏是一個很好的起點: http://loufranco.com/blog/understanding-exc_bad_access – KayAnn

回答

1

我設法調試,併成功地解決異常 - 顯然,它是由一個NULL0x00000000值造成的被前@property(nonatomic, retain) void (^registrationHandler)塊屬性指向Google's sample GCM v3 code for iOS。至於是Xcode,iOS還是cocos2d-x導致block聲明被取消引用/釋放,我不確定。

的解決方案是在(^registrationHandler)block declaration

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

移動到

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

相關SO鏈接這是有用的,但沒有真正的關鍵:unable to register (com.google.iid error 1005.)