🐛 Bug Report
Summary of Issue
On expo SDK38 bare workflow Android notifications stop after 5 minutes when the device is locked. Even when the notifications have priority: max
.
Environment – output of expo diagnostics
& the platform(s) you’re targeting
Expo CLI 3.21.13 environment info:
System:
OS: macOS 10.15.5
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.4.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
npmPackages:
expo: ~38.0.1 => 38.0.4
react: ~16.11.0 => 16.11.0
react-dom: ~16.11.0 => 16.11.0
react-native: ~0.62.2 => 0.62.2
react-native-web: ~0.11.7 => 0.11.7
npmGlobalPackages:
expo-cli: 3.21.13
package.json
{
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web"
},
"dependencies": {
"expo": "~38.0.1",
"expo-constants": "~9.1.1",
"expo-notifications": "~0.3.3",
"expo-permissions": "~9.0.1",
"expo-splash-screen": "~0.3.1",
"expo-status-bar": "^1.0.0",
"expo-task-manager": "^8.3.0",
"expo-updates": "~0.2.10",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "~0.62.2",
"react-native-gesture-handler": "~1.6.1",
"react-native-reanimated": "~1.9.0",
"react-native-screens": "~2.9.0",
"react-native-unimodules": "~0.10.1",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-jest": "~25.2.6",
"jest": "~25.2.6",
"react-test-renderer": "~16.11.0",
"babel-preset-expo": "~8.1.0"
},
"private": true,
"name": "test-notifications",
"version": "1.0.0"
}
Reproducible Demo
I cannot create a snack as it doesn’t seem to allow for modifying the app.json.
Repository: https://github.com/RodolfoGS/android-pn-stops
How to run the demo
- Clone https://github.com/RodolfoGS/android-pn-stops
yarn install
- Connect your device
yarn android
- Copy your Expo token from the console
- Disconnect and lock your device
watch -n 30 node push.js "__YOUR_EXPO_TOKEN_HERE__"
You will receive a notification every 30 seconds. Don’t touch your phone and keep it locked and disconnected. After 5 minutes you will stop receive notifications.
It happen when you have useNextNotificationsApi: true
or when you are in bare workflow. If you put it in false (managed only) it works.
Steps to Reproduce
If you want to reproduce it creating a new project just follow the next steps:
- expo init
- expo eject
expo install expo-notifications
expo install expo-permissions
expo install expo-constants
- run on your Android device (only affect Android devices)
- disconnect from the energy and lock your device
- send a push notification with
priority: max
, the notification appears. - keep the phone locked and wait 5 minutes…
- send a push notification with
priority: max
, the notification doesn’t appear. - send more notifications, don’t appear.
- when you unlock the device, all pending notifications appear at that moment.
Expected Behavior vs Actual Behavior
Expected Behavior: the notifications appear at the moment that has been pushed
Actual Behavior: the notifications don’t appear and when the user unlock the phone, the notifications come all at that time.
On expo sdk 36 with expokit works as expected, even when the device has been locked for hours.
I can reproduce always and easy, I just disconect the device and lock (turn off the screen), then I send a push notification every 30 seconds (with
push.js
that is in my demo) and ALWAYS at 5 minutes (exact) the notifications stop. Always when I test, always fails. Remember don’t unlock, nor connect, nor touch the notifications when came.And on the other hand, always when I change the flag of new notifications api to false, in the 100%% of the tests the notifications continue working for hours without touch the phone.
This also happen in the bare workflow, but is most simple to test in a managed because you can use the old api.
Surprising as it is, you’re right.
I haven’t paid enough attention to the fact whether my phone is connected or not, but was easiy able to reproduce that even on development client. That’s good news, hopefully we’ll be able to address the issue.
Thanks a lot for your cooperation so far!
Hey @RodolfoGS!
We found the root cause, but it turned to be more complicated than we anticipated. We need to do some major refactor of core notifications functionality in order to address this issue. We’re on it and it should land soon.
Fix has landed on master and will be published with new version od expo-notifications and on SDK39.
We’re considering backporting this change, stay tuned 😉 For now, official message is: It will be part of SDK39.