plugin notification iid failed error domain code clave autenticación apns ios firebase firebase-cloud-messaging

ios - notification - Firebase no pudo recuperar el token de APNS Error Domain=com.firebase.iid Código=1001 "(nulo)"



firebase cloud messaging ios (3)

Llama a este método y obtendrás el token del dispositivo. Y puedo ver el deviceToken impreso en la consola.

dispatch_async(dispatch_get_main_queue(), { global.appdel.tokenRefreshNotification() })

2016-08-22 18:34:50.108: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 2016-08-22 18:34:50.106 YAKKO[4269:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...) 2016-08-22 18:34:50.114: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" 2016-08-22 18:34:50.120: <FIRMessaging/INFO> FIRMessaging library version 1.1.1 2016-08-22 18:34:50.125: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO 2016-08-22 18:34:50.144 YAKKO[4269:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist 2016-08-22 18:34:50.188 YAKKO[4269:] <FIRAnalytics/INFO> Firebase Analytics enabled

Esta pregunta ha sido hecha antes . Pero aún no sé cómo solucionarlo. Las notificaciones no funcionan y la única ventaja que tengo es la línea: Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"

He comprobado dos veces que cargué los archivos .p12 correctos en Firebase. He entrado en Target -> -> Capabilities-> Background Modes-> remote-notifications y ON He verificado que mi bundleID coincida con GoogleService-Info.plist

Aquí está mi AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. FIRApp.configure() .... } func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { print("DEVICE TOKEN = /(deviceToken)") FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Sandbox) } func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { // If you are receiving a notification message while your app is in the background, // this callback will not be fired till the user taps on the notification launching the application. // TODO: Handle data of notification FIRMessaging.messaging().appDidReceiveMessage(userInfo) // Print message ID. print("Message ID: /(userInfo["gcm.message_id"]!)") // Print full message. print("%@", userInfo) } func tokenRefreshNotification(notification: NSNotification) { // NOTE: It can be nil here let refreshedToken = FIRInstanceID.instanceID().token() print("InstanceID token: /(refreshedToken)") connectToFcm() } func connectToFcm() { FIRMessaging.messaging().connectWithCompletion { (error) in if (error != nil) { print("Unable to connect with FCM. /(error)") } else { print("Connected to FCM.") } } }

Supongo que debería funcionar sin esos dos últimos métodos, pero los puse allí de todos modos (de acuerdo con las declaraciones impresas, no parece que los llamen).

Llamo registerForRemoteNotifications:

static func registerForNoties(){ let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound] let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(pushNotificationSettings) UIApplication.sharedApplication().registerForRemoteNotifications() }

Y puedo ver el dispositivoToken impreso en la consola. Pero sigo teniendo este problema con FireBase. ¿Alguna idea de otras cosas que pueda verificar?


Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" crear una aplicación simple basada en el ejemplo de Firebase / Quickstart-iOS para iOS (Swift) y tuve el mismo problema: Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" .

No pude recibir notificaciones mientras la aplicación estaba en segundo plano. Por lo tanto, he encontrado una solución que funcionó para mí aquí: https://github.com/firebase/quickstart-ios/issues/103

Básicamente, agregué este método:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { print("Handle push from background or closed" ); print("%@", response.notification.request.content.userInfo); }

... y esta línea de código:

application.registerForRemoteNotifications()

Aparentemente, el ejemplo escrito en Objective-C funciona bien, pero al ejemplo en Swift le faltan algunos fragmentos de código y no funciona como se esperaba ...


Intenta actualizar Firebase / Core a v3.4.4, solucionó errores inesperados para mí. De lo contrario, intente evitar llamar a unregisterForRemoteNotifications . Después de esta llamada, ya no puede registrar el dispositivo para enviar notificaciones. Además, intente configurar FirebaseAppDelegateProxyEnabled en NO en su archivo info.plist. Creo que hay errores con su método swizzling.