Skip to content
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

Conversation

lukmccall
Copy link
Contributor

@lukmccall lukmccall commented May 22, 2020

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

@lukmccall lukmccall requested a review from sjchmiela May 22, 2020 15:34
Comment on lines 62 to 66
public void onFailure() {
Log.w("expo-notifications", "Couldn't get experience from remote message.", null);
dispatchToNewNotificationModule(remoteMessage);
dispatchToOldNotificationModule(remoteMessage);
}
Copy link
Contributor Author

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 🤔

Copy link
Contributor

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.

@github-actions
Copy link
Contributor

Native Component List for this branch is ready

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Comment on lines 62 to 66
public void onFailure() {
Log.w("expo-notifications", "Couldn't get experience from remote message.", null);
dispatchToNewNotificationModule(remoteMessage);
dispatchToOldNotificationModule(remoteMessage);
}
Copy link
Contributor

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() {
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

apps/test-suite/app.json Outdated Show resolved Hide resolved
Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cyk!

@lukmccall lukmccall merged commit 915140a into master May 22, 2020
@lukmccall lukmccall deleted the @lukmccall/expo-notifications/fix-double-notification-dispatch branch May 22, 2020 17:43
Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳🥳🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants