GCM IOS NotRegistered issue

Ich benutze GCM schon lange. Eines Tages brach es plötzlich. Das Problem ist, dass ich beim ersten Push, den ich sende, den Erfolgsstatus zurück bekomme, aber die App überhaupt keinen Push erhält. Der zweite Push, den ich sende, wird mit einem NotRegistered-Fehler fehlgeschlagen. Ich installiere die App neu: Erfolgreich (keine Benachrichtigung erhalten), Misserfolg (NotRegistered) -> Schleife. Ich weiß nicht, was sich geändert hat. Der Google-Support ist sehr wenig hilfreich und nimmt sich viel Zeit, um einfache Fragen zu beantworten, ob es sich um ein GCM-Problem, ein APN-Problem oder ein Client-Problem handelt. Wenn jemand zuvor ein solches Problem hatte, teilen Sie mir bitte mit, wonach zu suchen ist. So sieht es aus:

Ich vermute, dass es nach dem Update auf iOS 9 passiert ist. Ich bin mir jedoch nicht sicher. Wenn es Dinge in neuem iOS gibt, die GCM blockieren könnten, würde ich es begrüßen, wenn jemand darauf hinweist.

AKTUALISIEREN

GCM-Push schlägt mit NotRegistered @ fe

dieser Typ hatte ein ähnliches Problem. Das Problem war mit einer Manifestdatei. Könnte es einige Einträge in der Info.plist geben, die ich für iOS 9 hinzufügen muss, um GCM zuzulassen?

AKTUALISIEREN

onTokenRefresh wird bei jedem Start der App aufgerufen. Ich bekomme jedoch das gleiche Zeichen zurück. Ich vermute, es gibt ein Problem mit einem Token auf einem GCM-Server.

GCM CODE IN APPDELEGATE DELEGIEREN:

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]
}

AKTUALISIERE

OK, also glaube ich, dass ich den Ort der .plist durcheinander gebracht habe (es war aus irgendeinem Grund nicht im Stammverzeichnis). Ich bin in das Stammverzeichnis umgezogen und erhalte jetzt beim Starten von GCM die folgende Warnung bzw. den folgenden Fehler:

UPD. Okay, es ist tatsächlich nur einmal passiert und hat aufgehört. Ich glaube also nicht, dass das Problem hier liegt.

Nachdem ich .plist in das Stammverzeichnis verschoben habe, wurden die Aufrufe von onTokenRefresh () gestoppt, aber ich erhalte immer noch NotRegistered.

Antworten auf die Frage(2)

Ihre Antwort auf die Frage