1

I try to implement cloud messaging, and I'm facing with a problem, It makes my game terminate. But I don't have this problem with example project.

The relating class's GGLInstanceIDTokenManager, It's a private class in libGGLInstanceIDLib.a lib. The below is what I see on xCode log:

2015-06-16 18:13:04.446 BreezeGame[2307:427893] -[GGLInstanceIDTokenManager fetchTokenWithAuthorizedEntity:scope:keyPair:options:handler:]: unrecognized selector sent to instance 0x14681290
2015-06-16 18:13:04.713 BreezeGame[2307:427893] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GGLInstanceIDTokenManager fetchTokenWithAuthorizedEntity:scope:keyPair:options:handler:]: unrecognized selector sent to instance 0x14681290' 

Why didn't Xcode find fetchTokenWithAuthorizedEntity:scope:keyPair:options:handler: function ?

Please help me to fix it. I'm newbie with Cloud Messaging.

Thanh Vũ Trần
  • 792
  • 6
  • 15
  • Do you use `CocoaPods` in your project? If not, you can follow the steps in [this page](https://developers.google.com/cloud-messaging/ios/client). Also make sure you add the `GoogleService-Info.plist` to your project. – ztan Jun 16 '15 at 18:10
  • yes, I followed step by step in the guide. And sure I added GoogleService-Info.plist. I also created a new project, and It worked. So I still don't know why didn't Xcode find that function ? Do you know what some things are that cause problem ? – Thanh Vũ Trần Jun 17 '15 at 02:59
  • I think you were missing the -ObjC linker flag in your project file settings. Since the method is defined in a catgory and if you don't have the setting the linker is not going to add these category methods and it's going to fail. Here is more info on this http://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library – evanescent Jul 24 '15 at 22:26

2 Answers2

0

I just ran nm on the library and apparently there is an Internal category on GGLInstanceIDTokenManager which does declare this function,

libGGLInstanceIDLib.a(GGLInstanceIDTokenManager+Internal.o): 00001230 t -[GGLInstanceIDTokenManager(Internal) deleteRegisteredTokenWithAuthorizedEntity:scope:keyPair:handler:] 000029cc s -[GGLInstanceIDTokenManager(Internal) deleteRegisteredTokenWithAuthorizedEntity:scope:keyPair:handler:].eh 00000230 t -[GGLInstanceIDTokenManager(Internal) fetchTokenWithAuthorizedEntity:scope:keyPair:options:handler:] 00002894 s -[GGLInstanceIDTokenManager(Internal) fetchTokenWithAuthorizedEntity:scope:keyPair:options:handler:].eh

Not sure why it doesn't work for you. Maybe you should file a bug on gcm's github tracker.

evanescent
  • 1,373
  • 13
  • 20
0

My problem was that the bundle id of my app was not the same as the one in GoogleService-Info.plist

Aura
  • 246
  • 1
  • 10