[SDK38] Android notifications stop after 5 minutes

🐛 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:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
      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
      Android Studio: 4.0 AI-193.6911.18.40.6514223
      Xcode: 11.5/11E608c - /usr/bin/xcodebuild
      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
      expo-cli: 3.21.13


  "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

  1. Clone https://github.com/RodolfoGS/android-pn-stops
  2. yarn install
  3. Connect your device
  4. yarn android
  5. Copy your Expo token from the console
  6. Disconnect and lock your device
  7. 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:

  1. expo init
  2. expo eject
  3. expo install expo-notifications
  4. expo install expo-permissions
  5. expo install expo-constants
  6. run on your Android device (only affect Android devices)
  7. disconnect from the energy and lock your device
  8. send a push notification with priority: max, the notification appears.
  9. keep the phone locked and wait 5 minutes…
  10. send a push notification with priority: max, the notification doesn’t appear.
  11. send more notifications, don’t appear.
  12. 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.

ezgif com-video-to-gif

On expo sdk 36 with expokit works as expected, even when the device has been locked for hours.

5 thoughts on “[SDK38] Android notifications stop after 5 minutes

  1. 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.

  2. 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!

  3. 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.