-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Messages not received when registration is done after first app launch #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@pfrischmuth thanks for this. Can you note your iOS version and whether you've disabled method swizzling, since those are related to setup and may be needed for a repro? |
I tested on iOS 10.3. In the above example I did not disable method swizzling, but I also tried it with method swizzling disabled and the issue still occurs. |
Hmm this could be related to a bug I'm fixing in Instance ID that was introduced in the last release, where a race condition is created on first launch. (This is being fixed for the next release) Hmm, to confirm what you're saying:
Second Launch
I think I'm misunderstanding the issue, then. However, I want to clarify:
FCM / IID creates an FCM token whether or not you register for remote notifications, it's just that there is no APNs device token associated with that FCM token yet. When an APNs token is provided, the FCM token is updated on the backend to be associated with that APNs token, and notifications can now be sent via APNs using that FCM token. |
I tried with Firebase 3.15.0, 4.0.0 and 4.1.1. With both 4.x releases I can produce the issue, with the 3.x release it works as expected (although the API is slightly different). I don't even access the FCM token on first launch. I only call I do all the registration steps on the second launch (or later) and would expect that I can receive notifications afterwards, but this does not work for me (not with a 4.x SDK, with a 3.x SDK it works fine). However when I complete the registration process on first launch, I can receive notifications (with all tested versions of the SDK). I hope this clarifies my issue. |
Thanks @pfrischmuth for the detailed info. Yes, it sounds like the issue that is being fixed in Instance ID for the next release of Firebase. As a workaround for now, you should be able to call
Later on (in your second launch), you can always request permissions for user notifications as you have done before (i.e. Hope that makes sense! |
OK, thanks for the response. I will consider the workaround and look forward for a fix in the next release. |
Hi @pfrischmuth I'm trying to determine if the issue I'm seeing is the same as yours. Would it be possible to clarify: when you say "when I send a message via the Firebase console to that token, I will not receive the message.", did you see an error message in the console? (I am seeing "Unregistered Registration Token"). |
Hi @ChrisRicca No, I do not receive an error message in the Firebase Console. I see the usual "Done" state there, but the message is never received on the device. |
Fixed in Firebase 4.2.0 FirebaseInstanceID 2.0.3 released today. |
Unfortunately this fix does not solve my problem. I think I can narrow the issue down to an issue in FirebaseInstanceID, since when I try it with FirebaseInstanceID 2.0.0 it works fine. I tried the following versions:
I have a very simple app that just executes the following code on first launch (fresh install of the app):
On second launch of the app I execute the following code:
I think I can narrow it down to that calling |
I have reproduced this issue as well in our application using the latest release (Firebase 4.2.0 FirebaseInstanceID 2.0.3). At first, the push notifications silently fail as @pfrischmuth described. (I suspect over time they get cleaned up by the firebase system and start returning the "Unregistered Registration Token" error that I was seeing later.) We can probably call Relying on the initial |
@pfrischmuth and @ChrisRicca Thanks so much for the detailed info, particularly the app delegate differences between starts. I've reproduced the issue, and I'm working on a fix. Re-opening this issue. In the meantime, the workaround is to call
Curious, why is this not an option? FYI, this does not show a permissions dialog to the user, only the
Yeah, I'm really sorry for the bug 😞 . Assuming your app doesn't crash while fetching an FCM token, you should be fine. |
Thank you for the response. I have two concerns regarding always calling
|
@rsattar thanks for the response, and for being on the case. No need to apologize, bugs happen 🐞! We're implementing another push notification service using the raw APNS token so we can recover our users who are in a broken state, and then we'll switch back when the fix is up so I'm all set, but let me know if there's anything I can do to help. (Same to you @pfrischmuth) |
I can also still reproduce the issue in the given versions. Downgrading FirebaseInstanceID to 2.0.0 fixed it (thanks @pfrischmuth). |
Same problem for me, and same solution.
And Yes, i do ask for permissions, later. (not on first app launch). So to our user, the experience is unchanged. Just got to make sure our devs know to do this. We will be following this thread to see when we will be able to roll forward to FirebaseInstanceID latest. NOTE: Just doing # 1 does NOT solve the described problem. Tested on iOS Versions: 9, 10, 11. |
I didn't even do that, just downgraded to 2.0.0 and everything seems fine. |
this worked for me ios11, xcode 9, firebase 4.2, firemessaging... 2.0.3 Just dont call [FIRApp configure]; before [[UIApplication sharedApplication] registerForRemoteNotifications]; |
[SOLVED] ======== I am experiencing the same problem running Xcode 9. Just updated to Firebase pod v4.2.0 and forcing FirebaseInstanceId to v2.0.0 I followed Tom Kerpelman's article (https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.html) and get to where I send a curl request to FCM and get the multicast 'Success' message back in the terminal. Request Response However, it does not show up on my device. The test through Apple's API works fine on the same device. Using Firebase's Notification function in the Console does not work neither when sending to the app as to a single device (using a valid FCM Token). My podfile: I am also firing application.registerForRemoteNotifications() before I fire FirebaseApp.configure() in didFinishLaunchingWithOptions Any advice would be welcome. It all worked in a previous app built using Xcode 8. |
While my tests on both of my devices here were working fine fine, I have now one user reporting that push notifications are not working at all. As it's only one user, I don't want to draw any conclusions just yet. Still thought it's worth mentioning it here. Any ETA on when a fix will be released for this issue? |
Fix released today in Firebase 4.3.0, FirebaseMessaging 2.0.4, and FirebaseInstanceID 2.0.4 |
Awesome, thank you! |
The latest release fixes the issue for us. Thank you! 👍 |
@ChrisRicca how were you able to solve your issue "Unregistered Registration Token". |
I'm still getting the issue with Firebase 4.13.0, Messaging 2.2.0 and InstanceID 2.0.10. Just like @ashok1089; how do I fix the 'Unregistered Registration Token' error from the CM Console? What I tried and what failed:
My original setup was setting the token received in
To elaborate even more; I followed this blog post and verified that sending a message directly through APNs works (as in I receive the push message on my device).
I've got no clue now anymore. Ok...everything works again. And I've got no clue why, and I'm not sure if it will keep working with all the troubles I've had.
Now where does this differ? Here are a few pointers which 'may' help:
With the above things it now somehow works, but as I said before. No. Clue. Why. |
Environment
Describe the problem
Steps to reproduce:
When I register for push notifications directly when the app starts for the first time (after install), the registration process works and I can send a notification to my device via the Firebase console.
However when I do not register on first app launch (i.e. launching the app for the first time, stopping it and register on second launch), the registration process seems to succeed (I can access the FCM token), but when I send a message via the Firebase console to that token, I will not receive the message.
When I use (almost) the same code (changes only in the commented out lines, due to changes to the API) with a Firebase version <4.0.0 (e.g. Firebase 3.15.0), both cases work fine.
Relevant Code:
I created a very simple project that reproduces the problem. I comment out the code for the first launch and then do the registration on the second launch, which produces the issue.
The text was updated successfully, but these errors were encountered: