firebase-ios-sdk: Subscribing to topic on first app start fails without bg notifications and direct channel

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.4.1
  • Firebase SDK version: 5.4.0
  • Firebase Component: Messaging
  • Component version: 3.0.3

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Create a new project as described in https://firebase.google.com/docs/cloud-messaging/ios/client. Notably, don’t set up a direct channel; and don’t enable silent background notifications.

Try to subscribe to a topic on first app start after permissions are granted. Subscription will fail with error code 501 (kFIRMessagingErrorCodeMissingDeviceID). If logging is enabled, “Device check in error, no auth credentials found” is printed before.

(Tested on iOS 11.4 device.)

Relevant Code:

Use Messaging_Sample_iOS slightly modified by me here: https://github.com/herrernst/firebase-ios-sdk/tree/subscribing-bug.

Add a GoogleService-Info.plist. On first app start (remove app before trying again), click “Request User Notifications”. The completion block of subscribeToTopic will be called with an error. (You can probably ignore the thread checker warnings complaining about UI updates from background threads.)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

The fix doesn’t depend on the FirebaseMessagingAutoInitEnabled flag. We found out checkin is not considered valid during app first start, causing the very first call always failed. So this fix should resolve your issues.

This should be fixed in the next release; please re-open this issue if it regresses past that point.

@chliangGoogle @herrernst I’m also facing this issue. Usually, I subscribe to 4 topics at some point and indeed the 1st one fails on a first launch with error code 501.

I use default values for both shouldEstablishDirectChannel and FirebaseMessagingAutoInitEnabled. In fact, I don’t have such strings in my code whatsoever. Also, I use the same versions which @herrernst uses.

Let me know, if you need a debug log or something that might help.

I’m able to reproduce by turn off direct channel and disable auto collection ( put FirebaseMessagingAutoInitEnabled in info.plist).

Thank you for reporting this issue, we are working on a fix for it.