Swift 包 ID 错误中的 GCM

GCM in Swift Bundle ID Error

我在 Swift 中执行 Google 云消息传递时遇到问题。将 GCMExample 用于 objective C 我正在获取注册令牌,但是当我尝试 运行 GCMExampleSwift 用于 Swift 时,我收到了一个错误。我对 Objective C 和 Swift 使用相同的 'GoogleService-Info.plist'。

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

GoogleService-Info.plist 中的 Bundle ID 似乎与您目标中的 Bundle ID 不匹配。

首先你需要将 GoogleService-Info.plist 文件添加到正确的目标,如果你正在尝试 GcmExampleSwift,你应该 select 作为目标:

然后在你的 GoogleService-Info.plist 文件中,如果你想使用 com.XXXXXX.mobility.appfactory.dev1.social 作为你的包 ID,请确保你在 BUNDLE_ID 键中正确拼写它:

最后,在你的目标中,确保你首先 select GcmExampleSwift(不是 GcmExample,它是 Objective - C 目标),然后制作Bundle Identifier 匹配 GoogleService-Info.plist 文件中的 BUNDLE_ID