我的代码与here基本相同。 我正在关闭应用程序的情况下进行测试,点击收到的通知。在生产应用程序中未命中 addNotificationResponseReceivedListener 下注册的函数。点击通知会导致应用程序启动(进入前台),但不会调用已注册的通知侦听器。
我将代码移至 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": "..."
}
}
我最好的猜测是我在“发布”配置中遗漏了一些内容,但我不知道。据说我遵循了文档中的所有步骤(https://docs.expo.dev/versions/latest/sdk/notifications/#usage),它按预期在开发模式下工作。 我做的唯一不同的事情是不在 App.js 中挂钩侦听器,而是在其始终处于打开状态的直接子组件 Main.js 中挂钩...