Notification is not received on Android when app is in background
See original GitHub issueAfter using BackHandler.exitApp()
the app is moved into the background and onNotification
callback is not triggered anymore. I’ve noticed that upon moving the app to the background manually, everything works fine.
Btw I have configured launch mode as suggested in other tickets:
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
I also tried to detect the moment when app goes to the foreground and use popInitialNotification
but unfortunately the message received in this manner doesn’t contain either data
or message
fields. Not sure why
AppState.addEventListener('change', this._handleAppStateChange);
_handleAppStateChange = (nextAppState) => {
if (nextAppState === 'background') {
PushNotification.popInitialNotification((ev) => {
console.log('initial notification', ev)
})
}
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
Firebase onMessageReceived not called when app in ...
When app is in background, Notification messages are delivered to the system tray. If the app is in the foreground, messages are handled...
Read more >How exactly do apps not running "in the background" receive ...
When you install a new app on your phone that uses push notifications, and give it permission to access the internet, it registers...
Read more >Android - Not receiving Background notification · Issue #3652
Not receiving push notification in android when an app is in background doesn't really help us help you. We need to see your...
Read more >Receive messages in an Android app - Firebase - Google
When your app is in the background, Android directs notification messages to the system tray. A user tap on the notification opens the...
Read more >Restrictions on starting activities from the background
In nearly all cases, apps that are in the background should display time-sensitive notifications to provide urgent information to the user instead of ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
what about for ios. can you help me
Adding this to AndroidManifest.xml
<activity android:name=“.MainActivity” android:launchMode=“singleTask”
This worked for me.