My code is basically the same like here. I'm testing with the App closed, tapping on a received notification. The registered function under addNotificationResponseReceivedListener is not being hit in the production app. Tapping the notification causes the app to start (comes to the foreground), but no registered notification listener is called.

I moved the code to the App component and the behavior is the same.

The "development build" is done using:

eas build --profile development --platform android

The "release" build is done using:

eas build -p android

My eas.json looks like:

{
  "cli": {
    "version": ">= 3.7.2",
    "appVersionSource": "local"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "preview": {
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "production": {
      "autoIncrement": false,
      "ios": {
        "resourceClass": "m1-medium"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

My app.json (I removed some data, substituted it by "..."):

{
  "expo": {
    "name": "...",
    "slug": "...",
    "version": "1.0.25",
    "orientation": "default",
    "icon": "./assets/big-head.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/big-head.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "buildNumber": "4",
      "supportsTablet": true,
      "config": {
        "usesNonExemptEncryption": false
      },
      "infoPlist": {
        "NSFaceIDUsageDescription": "Allow $(PRODUCT_NAME) to use Face ID."
      }
    },
    "android": {
      "versionCode": 36,
      "adaptiveIcon": {
        "foregroundImage": "./assets/big-head.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "...",
      "permissions": [
        "android.permission.CAMERA",
        "android.permission.RECORD_AUDIO",
        "android.permission.USE_BIOMETRIC",
        "android.permission.USE_FINGERPRINT"
      ],
      "googleServicesFile": "./google-services.json"      
    },
    "web": {
      "favicon": "./assets/favicon.png",
      "bundler": "metro"
    },
    "extra": {
      "eas": {
        "projectId": "..."
      }
    },
    "plugins": [
      [
        "expo-camera",
        {
          "cameraPermission": "Allow $(PRODUCT_NAME) to access your camera."
        }
      ],
      [
        "expo-local-authentication",
        {
          "faceIDPermission": "Allow $(PRODUCT_NAME) to use Face ID."
        }
      ],
      [
        "expo-document-picker",
        {
          "iCloudContainerEnvironment": "Production"
        }
      ],
      "expo-localization",
      "expo-secure-store",
      [
        "expo-notifications",
        {
          "icon": "./assets/big-head.png",
          "color": "#ffffff"
        }
      ]
    ],
    "owner": "...",
    "scheme": "..."
  }
}

My best guess is I'm missing something in the configuration for "release", but I have no idea. Supposedly I followed all the steps in the documentation (https://docs.expo.dev/versions/latest/sdk/notifications/#usage), it works in development mode as expected. The only thing I do differently is hooking the listeners not in the App.js but in its direct child component Main.js that is always on...

1

There are 1 best solutions below

0
Sammybar On

After much testing, and building, (and waiting in the Expo's free tier queue...) It looks like the only that works as expected is the useLastNotificationResponse() hook.

The provided example (see here) works both in the development build and in the production build, reacting to tapping the notification.

Anyway this answer looks more like a workaround than a good answer because...

...why these listeners are not being called...?