GCM IOS NotRegistered issue

I have been using GCM for a long time. Once he suddenly broke. The problem is that the first click I submit returns a success status, but the application does not receive any click. The second click that I send fails with a NotRegistered error. I reinstall the application: success (without receiving notification), failure (NotRegistered) -> Loop. I do not know what has changed. Google support is very useless and takes a long time to answer a simple question: is this a GCM problem, an APN problem, or a client problem. If anyone had such a problem before, please let me know what to look for. Here's what it looks like:

Here is the HTTP protocol

I suspect this happened after upgrading to iOS 9. However, I'm not sure. If there are things in the new iOS that can block GCM, I would appreciate it if anyone pointed this out.

UPDATE:

GCM Error with NotRegistered

this guy had a similar problem. The problem was with some manifest files. Could there be some entries in Info.plist that I need to add for iOS 9 in order to enable GCM?

UPDATE:

onTokenRefresh is called every time the application starts. However, I get the same sign. I suspect a marker issue on the GCM server.

GCM DELEGATE CODE IN 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

OK, so I think I ruined the place .plist (for some reason it was not in the root directory). I went to the root and now I get this warning / error when starting GCM:

UPD Okay, this happened only once and stopped. Therefore, I do not think the problem is here.

After I moved the .plist to the onTokenRefresh () root directory, the calls stopped, but I still get NotRegistered.

Error

+6
source share
1 answer

So, I solved the problem. It turned out that I did not use the correct iOS Development Provisioning Profile. I used generic, while I needed to use a specific package for my name. The reason this happened was because I reinstalled my OS a week ago or so, so the other certificate was destroyed and didn't work until I downloaded and manually added it to Xcode. I also needed to remove the team provisioning profile from the device. Totally not a GCM or APN error.

+5
source

All Articles