addNotificationResponseReceivedListener not firing from deadstart on Android / Managed / SDK 40.0 (w/ MCVE)

TLDR;

Having "fallbackToCacheTimeout": 30000 in your app.json (which I believe is the default anyway) will prevent addNotificationResponseReceivedListener from firing on android, managed, SDK 40 (or 39) from app killed if you have background location also running (startLocationUpdatesAsync).


For the past two releases (39 and 40) on managed, I’ve been experiencing a specific issue where:

  1. On my Android version 9 (cannot be upgraded to newer versions) on Galaxy S8 AND
  2. If background updates task is running AND
  3. You press on a notification…. AND
  4. From a deadstart…

… the addNotificationResponseReceivedListener will not pick it up even if I put it in global scope at the very very very top of my app.tsx file so that it is the first thing that runs. Yes, I’ve even tried the useLastNotificationResponse hook and, of course, didn’t work because it’s also relying on the addNotificationResponseReceivedListener.

I didn’t want to file an issue until I had a MCVE for you guys because of how much discussion has already circulated on without anyone at Expo being able to repro it.

Well, I’m happy to announce that after 20 hours I finally got one for you and it’s pretty bare bones:

Essentially the fallbackToCacheTimeout is causing the issue.

So, this works:

    "updates": {
      "enabled": true,
      "checkAutomatically": "ON_LOAD"
    },

This doesn’t:

    "updates": {
      "fallbackToCacheTimeout": 30000,
      "enabled": true,
      "checkAutomatically": "ON_LOAD"
    },

I believe these settings are essentially the defaults for the “updates” key. I added them a few months to solve some other bugs. I’m worried if I remove these, something will break which I won’t find out about for a while.

This is indeed a very strange issue, one that I’m sure others with this key/value in app.json are likely experiencing. For now, I’m going to remove "fallbackToCacheTimeout": 30000 as I don’t think it will change the behavior of my application.

Here is a video with the issue:


IMG_0054.2.mp4


MCVE:

https://github.com/Aryk/expo-repro

cc @cruzach @sjchmiela

1 possible answer(s) on “addNotificationResponseReceivedListener not firing from deadstart on Android / Managed / SDK 40.0 (w/ MCVE)

  1. hey @Aryk , thanks for this! I confirmed the behavior: with "fallbackToCacheTimeout": 30000 and while running background location updates, notification responses while the app is killed can be lost (FYI for anyone reproducing this, you’ll need to add in a request for location permissions in order to get this to work:
    app.tsx:

     const [permission, askPermission] = Permissions.usePermissions(
        Permissions.LOCATION
      );
      // then add `askPermission` to start() function
    

    and add to app.json:

    android: {
    ...
          "permissions": [
            "ACCESS_BACKGROUND_LOCATION",
            "ACCESS_COARSE_LOCATION",
            "ACCESS_FINE_LOCATION"
          ]
    }
    

    I think @esamelson may have some insight here since the updates.fallbackToCacheTimeout key is relevant (although afaik 30000 is the default so not sure why specifying that changes anything)