2016-06-25 41 views
6

L'esecuzione dell'applicazione demo FCM sul mio iPhone non funziona - L'ID Firebase è nil.L'ID istanza FCM di Firebase è nullo (l'applicazione di avvio rapido sul dispositivo reale)

Procedura per riprodurre:

  1. pod try Firebase, e corrono 10: quickstart-ios/messaging/FCM.xcodeproj
  2. copiare il mio file di GoogleService-Info.plist nel progetto
  3. eseguire l'applicazione su un iPhone 5s (iOS 9.3.2)
  4. Accettare il finestra di dialogo che richiede l'autorizzazione per inviare notifiche
  5. Fare clic sui pulsanti
  6. Il token ID istanza è nullo

mio Mac ha i certificati adeguati per sviluppare e distribuire le applicazioni:

  1. ho sia la distribuzione iOS e iOS sviluppo provisioning profili, scelti utilizzando il 'automatica' impostazioni.
  2. Ho installato sia la distribuzione iOS e certificati di sviluppo iOS, in codice firmato con il 'automatica: sviluppatore iPhone' opzione
  3. ho la 'produzione' certificato SSL installato: "Apple Push Notification servizio SSL (Sandbox & Production)"

vedo un sacco di rumore nei log, ma l'errore più significativo è questo:

Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 

Ecco l'output della console completa:

2016-06-25 16:15:08.339 FCM[7398:4128979] Configuring the default app. 
2016-06-25 16:15:08.383 FCM[7398:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started 
2016-06-25 16:15:08.396: <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-06-25 16:15:08.397: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" 
2016-06-25 16:15:08.403: <FIRMessaging/INFO> FIRMessaging library version 1.1.0 
2016-06-25 16:15:08.413: <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-06-25 16:15:08.443 FCM[7398:] <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-06-25 16:15:08.508 FCM[7398:] <FIRAnalytics/INFO> Firebase Analytics enabled 
2016-06-25 16:15:08.538: <FIRInstanceID/WARNING> APNS Environment in profile: development 
2016-06-25 16:15:08.848 FCM[7398:4128979] Connected to FCM. 
2016-06-25 16:15:08.893: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:15:22.311: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:15:36.774 FCM[7398:4128979] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)" 
2016-06-25 16:15:40.552 FCM[7398:4128979] Subscribed to news topic 
2016-06-25 16:15:43.100 FCM[7398:4128979] InstanceID token: (null) 
2016-06-25 16:15:49.036: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:16:31.022: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:17:32.976: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:17:32.976: <FIRInstanceID/WARNING> Failed to retrieve the default GCM token after 5 retries 
2016-06-25 16:19:10.662 FCM[7398:4128979] InstanceID token: (null) 
2016-06-25 16:19:10.980: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" 
2016-06-25 16:19:10.981: <FIRInstanceID/WARNING> Failed to retrieve the default GCM token after 5 retries 
+0

Vedendo lo stesso su un iPad 2 (9.3). – IanS

+0

Si noti che il problema si verifica solo quando si esegue la distribuzione su un dispositivo reale. Funziona perfettamente nel simulatore, il che significa che il mio profilo di provisioning e i miei certificati sono corretti, giusto? – IanS

+0

Possibile duplicato di [notifica APNS Firebase non è riuscito a recuperare il token] (http://stackoverflow.com/questions/37438369/apns-firebase-notification-failed-to-fetch-token) –

risposta

1

Ho appena eseguito lo stesso codice sul simulatore (iPhone 5, iOS 9.3) e ottengo un token senza problemi.

lo faccio vedere un sacco degli stessi avvisi, anche se ...

2016-06-25 16:38:31.353 FCM[2546:42455] Configuring the default app. 
2016-06-25 16:38:32.561 FCM[2546:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started 
2016-06-25 16:38:32.833 FCM[2546:] <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-06-25 16:38:32.901: <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-06-25 16:38:32.928: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)" 
2016-06-25 16:38:32.971: <FIRMessaging/INFO> FIRMessaging library version 1.1.0 
2016-06-25 16:38:33.189: <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-06-25 16:38:51.094: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION} 
2016-06-25 16:38:51.096: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=NSCocoaErrorDomain Code=3010 "REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION" UserInfo={NSLocalizedDescription=REMOTE_NOTIFICATION_SIMULATOR_NOT_SUPPORTED_NSERROR_DESCRIPTION} 
2016-06-25 16:38:51.140 FCM[2546:42883] CFNetwork SSLHandshake failed (-9806) 
2016-06-25 16:38:51.141 FCM[2546:42883] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9806) 
2016-06-25 16:38:51.460 FCM[2546:42455] Connected to FCM. 
2016-06-25 16:38:56.709 FCM[2546:42455] InstanceID token: fgbPv5tnsPk:APA91bHUWOmuLmd4UkLXcp3Lysp92fH6bOb7tfmbjHehFOt_NPnc6tnMk-7YT51VASkk-dyHZAl01QRcedwqGUhHMiIXeV_xknBXppncu0WyjKLYhaVQ08bYKNZ5M1CuSjtk9l0HPyJX 
2016-06-25 16:38:56.711 FCM[2546:42455] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)" 
2016-06-25 16:38:57.505 FCM[2546:] <FIRAnalytics/INFO> Firebase Analytics enabled 
2016-06-25 16:40:03.845 FCM[2546:42455] Unable to connect to FCM. Error Domain=com.google.fcm Code=2001 "(null)" 
2016-06-25 16:40:06.534 FCM[2546:42455] InstanceID token: fgbPv5tns9...... 
0

Il problema era dovuto al mio uso del certificato 'Produzione' SSL, invece di uno del 'Sviluppo'. L'installazione sembrava risolvere le cose.

Ho assunto erroneamente che entrambe le versioni di sviluppo e produzione sarebbero gestite dal certificato "Servizio di notifica push Apple (SSL Sandbox & Produzione)". Questo potrebbe essere il caso degli APN nativi, ma non funziona per Firebase.

0

per me, se è successo quando non uso FIRAuth prima di ottenere i valori da Firebase.

FIRAuth.auth()?.signIn(withEmail: "[email protected]", password: "123456", completion: { (user, error) in 
if(error != nil){ 
    print(error) 
    return 
} 


let ref = FIRDatabase.database().reference(fromURL: "https://firdemo-84b6b.firebaseio.com/").child("users") 

ref.observe(.value, with: { (snapshot) in 
    print(snapshot.key) 
    print(snapshot.value) 
    }, withCancel: { (error) in 
     if(error != nil){ 
      print(error) 
      return 
     } 
    }) 

}) 

Si prega di provare. E fammi sapere se non funziona.

3

Provare ad aggiornare Firebase/Core alla v3.4.4, ha risolto gli errori imprevisti per me. In caso contrario, le correzioni tipiche sono:

  • Abilitazione Push Notifications sotto l'app Capabilities
  • evitare di chiamare unregisterForRemoteNotifications. Dopo questa chiamata, non è più possibile registrare il dispositivo per inviare notifiche.
  • Impostazione FirebaseAppDelegateProxyEnabled a NO nel file info.plist. Penso che ci siano bug con il loro metodo di swizzling.
  • Calling [[FIRMessaging messaging] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeUnknown] nel metodo didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken