ios - Swift Bundle ID 错误中的 GCM

标签 ios swift google-cloud-messaging bundle-identifier

我在 Swift 中执行 Google Cloud Messaging 时遇到问题。将 GCMExample 用于 objective-c ,我得到了注册 token ,但是当我尝试运行用于 Swift 的 GCMExampleSwift 时,我收到了一个错误。我为 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,则应选择它作为目标:

enter image description here

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

enter image description here

最后,在您的目标中,确保首先选择 GcmExampleSwift(不是作为 Objective - C 目标的 GcmExample),然后制作 Bundle IdentifierGoogleService-Info.plist 文件中的 BUNDLE_ID 匹配:

enter image description here

关于ios - Swift Bundle ID 错误中的 GCM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33361326/

相关文章:

ios - 如何将自动缩小应用于 UIButton 标题?

android - 应用程序运行时如何在android中以编程方式关闭通知?

android - GCM 有多少个 3rd 方服务器可以使用单个服务器 key ?

objective-c - UITableViewCell 子类在所有 super 方法上都出现构建错误

ios - 使用 Restkit 中的 RKObjectManager 在 https 和 http 之间切换的最佳方法是什么?

ios - 如何在出现 TouchID 警报时删除状态栏?

swift - 将 NSArray 转换为 NSDictionary

ios - 无法将错误 16 位或 P3 Assets 发布到 App Store iOS 应用程序?

ios - UILabel 未使用 UITableViewCell 自定义类 Swift 进行更新

android - 内部错误 : retry receiver class not set yet