Unable to get push notification data via props.exp.notification when app is closed

Please provide the following:

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS/web/all): Android

My app’s props.exp.notification value is NOT set at the root component when I open a push notification sent to my phone while the app was closed. I’ve seen some other closed posts (props.exp.notification is not working) about the same thing and haven’t found an answer.

To reproduce:

  1. Close my app on my mobile device
  2. Send an app notification using the Expo service
  3. Tap/select on the push notification on my phone

So I figured out the problem. Make sure the Expo app on your phone does NOT include SDK version 36 and you are using SDK 35 for everything in the app.json and package.json files! It should look like this when you open the Expo app on your device and tap on Projects at the bottom left:

Here is a link to the issue about selected notifications from a closed app NOT being passed into the app via props nor the listener mentioned in this doc. More importantly, the Expo app on my phone kept auto-updating to include SDK 36 which caused a ton of confusion so in my testing it would sometimes work then stop working after the app was updated the next day.

So here is a quick checklist to make sure Push Notifications work:

  • Use a physical device for testing as push notifications don’t work on emulators.
  • Make sure your mobile app is running Expo without version 36 in the supported SDK’s because it won’t work even if the app.json and package.json files reference SDK 35.
  • Make sure you *app.json* and *package.jso*n files reference SDK 35:

app.json:


{
  "expo": {
    "entryPoint": "./app/App.js",
    "name": "My App Name",
    "slug": my-app",
    "privacy": "unlisted",
    "sdkVersion": "35.0.0"
    ...
  }
}

package.json:


{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/netinfo": "^4.6.1",
    "axios": "^0.19.0",
    "expo": "^35.0.0",
    "expo-application": "~1.0.0",
    "expo-av": "~7.0.0",
    "expo-device": "~1.0.0",
    "expo-image-manipulator": "~7.0.0",
    "expo-image-picker": "~7.0.0",
    "expo-location": "~7.0.0",
    "expo-permissions": "~7.0.0",
    "expo-secure-store": "~7.0.0",
    "js-base64": "^2.5.1",
    "moment": "^2.24.0",
    "pusher-js": "^5.0.3",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
    ...
  }
}

So if you follow the checklist you should see the following in your app’s props, as well as your listeners for push notifications get called at startup after selecting a push notification when the app is closed:

App props:


{
  "notification": "{\"message\":\"my 2nd test notification",\"title\":\"notification title\"}",
  "exp": {
    "initialUri": "exp://127.0.0.1:19000",
    "notification": {
      "message": "my test notification",
      "notificationId": 288061067,
      "data": "{\"message\":\"my 2nd test notification",\"title\":\"notification title\"}",
      "isMultiple": false,
      "experienceId": "@mritzman-dg/my-app",
      "remote": true,
      "origin": "selected"
    },
    "unreadNotifications": [
      {
        "message": "first test notification",
        "notificationId": 288061067
      }
    ],
    ...
}

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.