Closed gminator closed 3 years ago
@gminator hi, sorry for the delay, I've taken a look and you are right - there was a typo to the docs in the example code which counteracted the text.
If you change the following code:
notifee.registerForegroundService(async (notification) => {
//...
})
to
```js
notifee.registerForegroundService((notification) => {
return new Promise(() => {
// Long running task...
});
});
it should persist. Hope that helps.
Summary
I'm seeing some strange behavior when using displayNotification with asForegroundService: true...
The notification appears for a brief moment and then disappears again. I can't get it to stay unless I deliberately break the javascript inside notifee.registerForegroundService. I write some broken code, it will but every subsequent call to displayNotification works as expected.
It also behaves as expected asForegroundService is not set
Reproducible sample code
This solution below doesn't, as mentioned the notification shows & vibrates for a second and then disabpears
This predictably fails 1st time, but every subsequent call after removing do.something.to.break.javascript works as expected
Environment info
npx react-native info
output: