Android发布构建中Expo Notifications的addNotificationResponseReceivedListener失效
Expo 通知点击无响应问题(生产构建)
我的代码和官方通知SDK示例基本一致,测试场景为App完全关闭时点击收到的通知:
- 开发构建下功能正常,点击通知能触发
addNotificationResponseReceivedListener对应的处理函数 - 生产构建中,点击通知只会把App拉到前台,但所有通知监听器都不会触发
已尝试将监听代码从Main.js(App的常驻直接子组件)移到App组件中,问题依旧。
构建命令
- 开发构建:
eas build --profile development --platform android - 发布构建:
eas build -p android
eas.json 配置
{ "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": {} } }
app.json 配置(省略部分内容)
{ "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": "..." } }
怀疑是生产构建的配置存在遗漏,但无法确定具体问题。已按官方文档步骤操作,唯一差异是监听器最初未挂载在App.js,而是挂载在其始终存在的直接子组件Main.js中。
内容的提问来源于stack exchange,提问作者Sammybar
相关产品推荐
相关产品推荐

