wix / react-native-notifications

React Native Notifications
MIT License
3.25k stars 764 forks source link

Fix for Android trampoline restriction #920

Closed ravirajn22 closed 1 year ago

ravirajn22 commented 1 year ago

When targeting Android 31, we cannot use a Service to start an Activity. So instead of using PendingIntent to start a Service we start an Activity directly.

Old flow Set PendingIntent for notification -> On press -> Start Service -> Start Activity if not visible

New flow Set PendingIntent for notification -> On press -> Start Activity

We already subscribe to Activity lifecycle event like created and onNewIntent, we use this callbacks to fire notification opened to JS.

I have tested the basic cases and its working fine. I want others to test against their cases and tell if Its working fine in those cases.

stale[bot] commented 1 year ago

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

FilDevTronic commented 1 year ago

Any updates on this from maintainers? My team is encountering the same issue - thank you for submitting this change @ravirajn22, we're testing it now.

b3itgustaf commented 1 year ago

Have you gotten around to taking a look at this PR @DanielEliraz ? This is currently a major blocker in our application since we're targeting SDK 31 and at the moment all notifications are discarded when tapping them instead of opening the app, because of this.

@ravirajn22 have you considered forking this repo until the code owners have had time reviewing this PR?

b3itgustaf commented 1 year ago

@DanielEliraz Is this repo abandoned? This PR is fixing a major issue in the library, and w/o this fix our project need to check in to another solution.

stale[bot] commented 1 year ago

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TwistedMinda commented 1 year ago

I'm still having the issue :(

Tapping on android notification where application is in foreground doesn't pass the Intent through

ovbm commented 1 year ago

I'm still having the issue :(

Tapping on android notification where application is in foreground doesn't pass the Intent through

Adding this version of firebase fixed the issue for us: https://github.com/republik/app/commit/2ca29d42d584520e6096d4f03326bb02e399935b

TwistedMinda commented 1 year ago

@ovbm Thanks for your help however it doesn't change anything on my side. Just to be sure that we are on the same bug: Tapping a notification:

The activity doesn't seem to really restart entirely: SplashScreen appears but the navigation state is preserved. It would still be okay if getInitialNotification() would return the notification tapped, but it's not.