GCM in Swift Bundle ID Error

允我心安 提交于 2019-11-28 11:15:39

问题


I am having trouble in executing Google Cloud Messaging in Swift. Using GCMExample for objective C I am getting the Registration token but when I am trying to run GCMExampleSwift which is for Swift I am getting an error. I am using the the same 'GoogleService-Info.plist' for both Objective C and Swift.

2015-10-26 17:31:59.834 GcmExampleSwift[360:51727] The configuration file 'GoogleService-Info.plist' is for another bundle identifier ('com.XXXXXX.mobility.appfactory.dev1.social'). Using this file the services may not be configured correctly. To continue with this configuration file, you may change your app's bundle identifier to 'com.XXXXXX.mobility.appfactory.dev1.social'. Or you can download a new configuration file that matches your bundle identifier from https:/ 2015-10-26 17:31:59.836 GcmExampleSwift[360:] App measurement v.1100000 started 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Successfully configured [CloudMessaging]. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Failed to configure []. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Subspecs not present, so not configured [Analytics, AdMob, SignIn, AppInvite, Maps]. 2015-10-26 17:31:59.843 GcmExampleSwift[360:51727] Subspecs expected to be present [CloudMessaging, Measurement]. 2015-10-26 17:31:59.936 GcmExampleSwift[360:] Network status has changed. code, status: 2, Connected 2015-10-26 17:31:59.977: GGLInstanceID | Unable to find token in cache Error Domain=com.google.iid Code=-25300 "(null)" Registration to GCM failed with error: The operation couldn’t be completed. (com.google.HTTPStatus error 401.) 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect 2015-10-26 17:32:01.053 GcmExampleSwift[360:51727] - changing property masksToBounds in transform-only layer, will have no effect


回答1:


Seems the Bundle ID in your GoogleService-Info.plist does not match the bundle ID in your target.

First you need to add the GoogleService-Info.plist file to a correct target, if you are trying the GcmExampleSwift, you should select that as the target:

Then in your GoogleService-Info.plist file, if you want to use com.XXXXXX.mobility.appfactory.dev1.social as your bundle ID, make sure you spell it correctly in for the BUNDLE_ID key:

Finally, in your targets, make sure you select the GcmExampleSwift first (NOT the GcmExample which is the Objective - C target), then make the the Bundle Identifier matches the BUNDLE_ID in your GoogleService-Info.plist file:



来源:https://stackoverflow.com/questions/33361326/gcm-in-swift-bundle-id-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!