firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.67k stars 1.49k forks source link

Received notifications are duplicated #8282

Closed IgorRosocha closed 3 years ago

IgorRosocha commented 3 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Since using Firebase Messaging 7.11.0, multiple users started to complain that after some time all of the notifications received from our apps are duplicated. We have currently received several reports from 2 of our production apps. Notifications are being sent using Firebase Console to relevant topics. Unfortunately, we were not able to reproduce this issue locally. Users also reported that issue got fixed by reinstalling the app.

However, we have noticed that in some cases, SDK sends multiple FCM tokens (4-6) in a row, f.e. right after reinstalling the app. Could the problem be related to incorrect behavior of SDK, leaving user with multiple valid FCM tokens? Has anyone experienced the same problem?

charlotteliang commented 3 years ago

@IgorRosocha Sending multiple FCM tokens (4-6) is definitely abnormal behavior. Although 7.11.0 is separating token logics between InstanceiD and messaging SDKs, so I suspect there might be some race conditions handling tokens between InstanceID and Messaging (even though we've tested that it shouldn't).

Our latest version no longer has InstanceID that should for sure resolve the suspicious condition above, would you mind updating to the latest SDK and remove InstanceID to try it out? The migration guide is here

IgorRosocha commented 3 years ago

@chliangGoogle thanks for you response!

Our latest version no longer has InstanceID that should for sure resolve the suspicious condition above, would you mind updating to the latest SDK and remove InstanceID to try it out? The migration guide is here

As mentioned above, first time user has reported the issue was from the version 7.11.0, but the latest report was actually from the latest 8.1.1 version of the SDK. We are using Carthage distribution and not calling InstanceID directly. I have noticed that we had InstanceID included in frameworks, so I have removed it. However, after launching the app again, I have immediately received 4 different FCM tokens in a row. However, I am not sure if this is the cause of the issue - when I tried sending notifications, they were delivered correctly.

charlotteliang commented 3 years ago

Can you share the debugLog with me? You can send me email at chliang@google.com.

IgorRosocha commented 3 years ago

Can you share the debugLog with me? You can send me email at chliang@google.com.

Sure, I have sent you debug log in email. You can also observe our custom logs with the [FCMTOKEN] prefix, which are printed whenever new FCM token is received in `messaging( messaging: Messaging, didReceiveRegistrationToken fcmToken: String?)`. In this case, 5 FCM tokens were recieved right after launching the app.

Looking forward to your response.

charlotteliang commented 3 years ago

Sorry for the delay, would you mind trying updating to our latest SDK that no longer requires InstanceID? The newer version of SDKs no longer deal with duplicate token logic in both SDKs (Messaging and InstanceID), and might resolve your issue.

google-oss-bot commented 3 years ago

Hey @IgorRosocha. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 3 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@IgorRosocha if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.