[英]Expo push notifications working on expo go but not working on apk ( production )
I'm trying to implement expo push notification .我正在尝试实施expo 推送通知。 I did everything as the docs say.
我按照文档所说的做了一切。 Created a firebase project and downloaded the
google-services.json
and uploaded the server key on the cloud messaging to expo servers using expo push:android:upload --api-key <your-token-here>
!创建一个 firebase 项目并下载
google-services.json
并使用expo push:android:upload --api-key <your-token-here>
将云消息上的服务器密钥上传到 expo 服务器! so basically I did everything mentioned on their docs!所以基本上我做了他们文档中提到的所有事情! My notifications works perfectly fine when I test it on the Expo GO !
当我在 Expo GO 上测试时,我的通知工作得很好! but after I built an apk using
eas build -p android --profile preview
The notification doesn't pop up?但是在我使用
eas build -p android --profile preview
apk 之后通知没有弹出? the api that I send from says that the notification was sent but it doesn't show on the device, I read that notifications work on expo go and not apk because of the credentials.我发送的 api 说通知已发送,但它没有显示在设备上,我读到通知在 expo go 上工作,而不是 apk,因为凭据。 did I miss a step or something.
我错过了一步还是什么。 When I go to the expo builds and go to the project credentials Two options pop up: One by the path of com.company.app and the other one : by Legacy ( classic build)!
当我 go 到 expo 构建和 go 到项目凭据弹出两个选项:一个通过 com.company.app 的路径,另一个:通过 Legacy(经典构建)!
app.json
{
"expo": {
"name": "myapp",
"slug": "myapp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
"googleServicesFile": "./google-services.json",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.hyrix.myapp",
"useNextNotificationsApi": true
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "ee001501-c3b5-402f-8a1d-914144496965"
}
}
}
}
You could check the Android Studios's logcat after connect your android smartphone to your PC.将 android 智能手机连接到 PC 后,您可以查看 Android Studios 的 logcat。
I've tried to debug the app in Android Studio's logcat and got the following error message:我尝试在 Android Studio 的 logcat 中调试应用程序并收到以下错误消息:
'[expo-notifications] Error encountered while updating the device push token with the server:', '{"errors":[{"code":"VALIDATION_ERROR","message":"\"appId\" must be a string.","isTransient":false}]}'
'[expo-notifications] 使用服务器更新设备推送令牌时遇到错误:', '{"errors":[{"code":"VALIDATION_ERROR","message":"\"appId\" 必须是字符串.","isTransient":false}]}'
What I did to solve this issue was set "applicationId" manually in the Notifications.getExpoPushTokenAsync()
method.我为解决此问题所做的工作是在
Notifications.getExpoPushTokenAsync()
方法中手动设置“applicationId”。 Ex:前任:
Notifications.getExpoPushTokenAsync({applicationId: "xxxxxx..."})
The applicationId
can be found in app's firebase config as appId
. applicationId
可以在应用程序的 firebase 配置中作为appId
找到。 The method getExpoPushTokenAsync()
can receive some parameters, maybe some of them are not being set correctly.方法
getExpoPushTokenAsync()
可以接收一些参数,可能其中一些参数设置不正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.