-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[expo-notification] Prevent from notification being dispatch twice #8437
[expo-notification] Prevent from notification being dispatch twice #8437
Conversation
public void onFailure() { | ||
Log.w("expo-notifications", "Couldn't get experience from remote message.", null); | ||
dispatchToNewNotificationModule(remoteMessage); | ||
dispatchToOldNotificationModule(remoteMessage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what should we do here 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too 🤔 Let's dispatch only to the old notifications module. 🤷 If no useNewNotificationsAPI
falls back to using the old module, no manifest should fall back the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
public void onFailure() { | ||
Log.w("expo-notifications", "Couldn't get experience from remote message.", null); | ||
dispatchToNewNotificationModule(remoteMessage); | ||
dispatchToOldNotificationModule(remoteMessage); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too 🤔 Let's dispatch only to the old notifications module. 🤷 If no useNewNotificationsAPI
falls back to using the old module, no manifest should fall back the same.
@@ -31,7 +38,40 @@ public void onMessageReceived(RemoteMessage remoteMessage) { | |||
return; | |||
} | |||
|
|||
ExponentDB.experienceIdToExperience(remoteMessage.getData().get("experienceId"), new ExponentDB.ExperienceResultListener() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does searching for it asynchronously work ok even when the app is terminated? What I'd be afraid of is starting new threads in a time-limited call-to-service. I believe Android catches it and doesn't terminate the app while the asynchronous callback is being executed, but who knows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be on the safe side — do you think this work ok in standalone apps too? Should we add a note somewhere to ensure test this there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I've tested it and it seems to work even if the app was killed. But maybe, we should switch to sync the call 🤔
I believe that will work in standalone apps. However, we should test it :D
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cyk!
android/expoview/src/main/java/host/exp/exponent/fcm/ExpoFcmMessagingService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳🥳🥳
Why
Parts of #8135.
How
Now, the user can specify which notification will be used on Android.
The scheme update: https://github.com/expo/universe/pull/5048
Test Plan