React-native-push-notification: onNotification does not fire when app in background

Created on 22 Dec 2019  路  18Comments  路  Source: zo0r/react-native-push-notification

Please help me! I use your module and after tow week in a test I understood that when app is closed or in foreground everything is well but if my app is in background onNotification does not call.
i follow this post https://product.farewell.io/visible-react-native-push-notifications-that-work-on-both-ios-and-android-5e90badb4a0f
but it can not solve my problem.

Most helpful comment

just add this: android:launchMode="singleTask"

AndroidManifest.xml

<activity
        android:name=".MainActivity"
        android:launchMode="singleTask"

All 18 comments

Please help me! I use your module and after tow week in a test I understood that when app is closed or in foreground everything is well but if my app is in background onNotification does not call.
i follow this post https://product.farewell.io/visible-react-native-push-notifications-that-work-on-both-ios-and-android-5e90badb4a0f
but it can not solve my problem.

just add this: android:launchMode="singleTask"

AndroidManifest.xml

<activity
        android:name=".MainActivity"
        android:launchMode="singleTask"

and this: https://github.com/surialabs/react-native-push-notification/commit/39d7adb

will help you with abandonPermissions for android, those who made this module probably forgot about android ...

That worked for me @prih.

@prih's solution works, thanks! I know nothing about Android, so I wonder what else changing the launchMode will affect.

link fixed...

@prih I tried your solution, but didn't worked, I'm having the same issue.

@prih I tried your solution, but didn't worked, I'm having the same issue.

android?

@prih yes, using FCM

@prih also setting popInitialNotification to true works when app is killed but the notification never clears after reading it.

@artmerlop hmm... did not meet such a problem.

@prih however the main issue that I can't solve is the onNotification not firing when the app is inactive but not killed.

Hi,
This issue should be fixed on 3.3.1.

@Dallas62

Hi,
This issue should be fixed on 3.3.1.

Still having this issue on 3.3.1

@Dallas62

Hi,

This issue should be fixed on 3.3.1.

Still having this issue on 3.3.1

Hi,

Can you provide more information?

  • OS ?
  • AndroidManifest
  • Implementation ?
  • reproductible example?

Note that onNotification will not be called if the app is killed/background. Only if the user press the notification when the app is killed/background.

@Dallas62 I'm on iOS. Works fine for local notifications, but it's not being called when the notification is pressed when the app is in the background. I'm also using react-native-firebase/messaging to get the FCM token.

For iOS, I suggest you to take a look to the iOS library, react-native-community/push-notification-ios which is the Library for iOS.
This library just provide a binding over iOS library.
There is some issues on the case you reported.

@Dallas62 great thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmadallo1 picture ahmadallo1  路  3Comments

NiuQiaoling picture NiuQiaoling  路  3Comments

cookienawer picture cookienawer  路  3Comments

GastonEDiaz picture GastonEDiaz  路  3Comments

sungjinoh picture sungjinoh  路  3Comments