To reproduce:
Send an Android notification that does not contain a data element while the app is running in the background.
Tap on the notification in the notification centre.
Repeat a few times.
What I noticed is that when tapping the notification my app appeared to re-launch itself even though it was already running. After trying a couple of times I realised that the app was launching multiple copies of itself - each tap resulted in a new instance of the JS app... but only 1 runtime - so I have multiple apps running side by side with a single UI!
It does not appear to happen if the push notification contains a data element.
I'm having this same exact issue. Considering moving to a "data" payload, but would prefer to stay with the "notification" payload if at all possible. Any thoughts around this one?
@npomfret i'm having the same issue too. But i can't fix it with a data attribute. Am I doing it wrong? Can you show me how you fixed this?
I've not fixed it. @mikelambert have you any idea what's happening here?
So without a data payload, the onMessageReceived will get called when opening the notification. And this is where my changes get run, so it's likely related to my code. :( How are you verifying that there are multiple "apps" running, and what does that mean exactly?
This might be fixed by switching to headless tasks added in RN 0.36. Are we perhaps willing to break compatibility with RN versions older-than-that at this point? I'm focused on other things at the moment for the next couple months, but can do the migration the next time I dig into the mobile/notification code.
Alternately, comparing the Headless JS code and the RN-PN code developed independently, it looks like the only thing I had forgotten was the wake-lock (I think unrelated) and the listener-removal (maybe multiple identical listeners are the source of the problems?)
@npomfret @mikelambert thanks for your answers. I fixed my problems with an attribute in my AndroidManifest.xml. I added android:launchMode="singleTop" to the main activity element.
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
...
</activity>
Maybe this helps s.b. else!
@mikelambert sorry for the slow reply, been travelling. I like your theory about the listener removal.
Have you tried replacing your code with the built in RN headless tasks?
Nope. Please see the second paragraph of my message above. :p
The deep linking docs recommend "singleTask" - https://facebook.github.io/react-native/docs/linking.html -

I havent tried the push notification module yet. But does anyone know how that compares to with @jk94 approach above of android:launchMode="singleTop"?
Hi i'm currently having this issue, when app is in background and show localnotification it launch the app when i clicked on notification.
Is there any way to prevent app from launc ?
I'am using react-navigation
Why was this closed? What was the solution?
@raymatos issue still there with local notification in android , onNotification is not working...
@Dallas62 why this query has closed ? :(
Most helpful comment
@npomfret @mikelambert thanks for your answers. I fixed my problems with an attribute in my AndroidManifest.xml. I added
android:launchMode="singleTop"to the main activity element.Maybe this helps s.b. else!