FCM Error: Failed to fetch APNS token

6,589 views
Skip to first unread message

smat...@fieldlevel.com

unread,
Jun 7, 2016, 5:54:07 PM6/7/16
to Firebase Google Group
I'm trying to add FCM push notifications to my iOS app and I keep getting the error:

<FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"


I've double and triple-checked that my Firebase project is set up with the correct APNS certificates and verified that my application is provisioned properly to receive push notifications (by manually sending a message to APNS). I've tried all of the setup guides and enabling/disabling AppDelegate swizzling, but I'm never getting the kFIRInstanceIDTokenRefreshNotification so that I can get a FCM InstanceID. The API docs mention more detail about error codes "down below", but I can't seem to find anything that would point me in the right direction for what a "1001" error might mean.


Anyone have any ideas?

smat...@fieldlevel.com

unread,
Jun 7, 2016, 7:50:52 PM6/7/16
to Firebase Google Group
So looks like that error message was a red herring. When I tried logging every notification broadcast to NSNotificationCenter I stumbled across one with the name "

com.firebase.iid.notif.fcm-token" that contained a token that I was able to use to successfully send a push notification to my device via the FCM Console. Following that track I tried deleting and reinstalling the app on my device and when I agreed to allow push notifications the kFIRInstanceIDTokenRefreshNotification event was finally fired to allow me to grab the FCM token.


This seems problematic for anyone who has already set up their app to use push notifications, as the user has already agreed (or disagreed) to allow notifications so we'll never have a chance to grab and save off the FCM token. Is it safe to listen for the notification mentioned above to grab the token or is there some other method we should be using to safely obtain and store the FCM token for a user?

Vincent Grimaud

unread,
Jun 9, 2016, 10:39:47 AM6/9/16
to Firebase Google Group
Hello I have the same error... could you explain what did you don to resolve this ? Here are my logs :

 2016-06-09 12:12:47.723 myPhotoCalendar[1674:794492] Configuring the default app.

2016-06-09 12:12:47.758 myPhotoCalendar[1674:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started

2016-06-09 12:12:47.759 myPhotoCalendar[1674:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/Y0Yjwu)

2016-06-09 12:12:47.764: <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-09 12:12:47.768: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"

2016-06-09 12:12:47.776: <FIRMessaging/INFO> FIRMessaging library version 1.1.0

2016-06-09 12:12:47.784: <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-09 12:12:47.783 myPhotoCalendar[1674:] <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-09 12:12:47.821 myPhotoCalendar[1674:] <FIRAnalytics/INFO> Firebase Analytics enabled

2016-06-09 12:12:48.086: <FIRInstanceID/WARNING> APNS Environment in profile: (null)

2016-06-09 12:12:48.086: <FIRInstanceID/WARNING> No aps-environment set. If testing on a device APNS is not correctly configured. Please recheck your provisioning profiles. If testing on a simulator this is fine since APNS doesn't work on the simulator.

smat...@fieldlevel.com

unread,
Jun 9, 2016, 2:50:37 PM6/9/16
to Firebase Google Group
Looks like you are missing the correct provisioning profile. The important log statements in your case are the last two. The "Failed to fetch APNS token" error apparently doesn't mean anything since push notifications are working fine for me and I still get that message every time the app launches.
Reply all
Reply to author
Forward
0 new messages