GCM IOS NotRegistered问题

我已经使用GCM很长一段时间了。 有一天它突然爆发了。 问题是,我发送的第一个推我成功的地位,但应用程序没有收到任何推。 我发送的第二个推送失败,出现NotRegistered错误。 我重新安装应用程序:成功(没有收到通知),失败(NotRegistered) – >循环。 我不知道发生了什么变化。 对于GCM问题,APN问题还是客户端问题,Google的支持是非常无用的,而且花费了大量的时间来回答简单的问题。 如果有人有这样的问题,请让我知道要寻找什么。 这就是它的样子:

这里是HTTP日志

我怀疑是在更新​​到iOS 9之后发生的。我不确定。 如果在新的iOS中有可能阻止GCM的东西,我会感激,如果有人指出。

更新:

GCM推送失败NotRegistered

那家伙也有类似的问题。 问题是一些清单文件。 Info.plist中可能有一些条目需要添加到iOS 9以允许GCM?

更新:

每次应用程序启动时都会调用onTokenRefresh。 不过,我也得到了同样的道理。 所以在GCM服务器上有一个令牌存在问题,我怀疑。

GCM代码在APPDELEGATE:

var connectedToGCM = false private var deviceToken: NSData? var gcmSenderID: String! let authorizedEntity = "my GCM Sender_ID" public func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. var configureError:NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \(configureError)") gcmSenderID = GGLContext.sharedInstance().configuration.gcmSenderID // [END_EXCLUDE] // Register for remote notifications if #available(iOS 8.0, *) { let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) application.registerUserNotificationSettings(settings) application.registerForRemoteNotifications() } else { // Fallback let types: UIRemoteNotificationType = [.Alert, .Badge, .Sound] application.registerForRemoteNotificationTypes(types) } // [END register_for_remote_notifications] // [START start_gcm_service] let gcmConfig = GCMConfig.defaultConfig() GCMService.sharedInstance().startWithConfig(gcmConfig) return true } public func onTokenRefresh() { print("Token needs to be refreshed!") let options = [ kGGLInstanceIDRegisterAPNSOption : deviceToken!, kGGLInstanceIDAPNSServerTypeSandboxOption : true ] GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(authorizedEntity, scope: kGGLInstanceIDScopeGCM, options: options) { (token, error) -> Void in if error != nil { print("Error: \(error.localizedDescription)") } else { print("Token: \(token)") } } } public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) } public func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { let instanceIDConfig = GGLInstanceIDConfig.defaultConfig() instanceIDConfig.delegate = self // Start the GGLInstanceID shared instance with that config and request a registration // token to enable reception of notifications GGLInstanceID.sharedInstance().startWithConfig(instanceIDConfig) self.deviceToken = deviceToken } public func applicationDidEnterBackground(application: UIApplication) { GCMService.sharedInstance().disconnect() connectedToGCM = false } public func applicationDidBecomeActive( application: UIApplication) { print("App became active") UIApplication.sharedApplication().applicationIconBadgeNumber = 0 // Connect to the GCM server to receive non-APNS notifications GCMService.sharedInstance().connectWithHandler({ (NSError error) -> Void in if error != nil { print("Could not connect to GCM: \(error.localizedDescription)") } else { self.connectedToGCM = true print("Connected to GCM") // ... } }) } public func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) { print("Notification received: \(userInfo)") GCMService.sharedInstance().appDidReceiveMessage(userInfo) } public func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { print("Error registering") } public func application( application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) { print("Notification received(background): \(userInfo)") NotificationManager.sharedInsteance().parseNotification(userInfo) // This works only if the app started the GCM service GCMService.sharedInstance().appDidReceiveMessage(userInfo); // Handle the received message // Invoke the completion handler passing the appropriate UIBackgroundFetchResult value // [START_EXCLUDE] handler(UIBackgroundFetchResult.NewData); // [END_EXCLUDE] } 

UPDATE

好的,所以我相信我搞砸了.plist位置(由于某种原因,它不在根目录中)。 我转移到根目录,现在我得到这个警告/错误启动GCM时:

UPD。 好吧,它实际上只发生一次,停下来。 所以我不认为问题在这里。

我把.plist移动​​到根目录onTokenRefresh()后停止了,但我仍然得到NotRegistered。

错误

所以我解决了这个问题。 看来我没有使用正确的iOS开发configuration文件。 我使用的是一个通用的,而我需要使用一个特定的名称。 之所以发生是因为我在一个星期前重新安装了操作系统,所以其他的证书已经被删除,直到我下载并手动添加到Xcode。 我也需要从设备中删除团队configuration文件。 完全不是GCM或APN故障。