Expo Android应用程式,PushNotifications无法在独立的APK中运作吗? [英] Expo android app, PushNotifications doesn't work in standalone apk?
问题描述
我遇到了一个问题,当我通过expo客户端应用程序运行应用程序时,PushNotifications可以工作.但是,如果我要构建独立的.apk,则需要安装expo客户端,以获取pushtoken.而且,当expo客户端未打开时,我无法获得pushtoken.因此,我的客户需要安装2个应用.一种是我的,构建独立的.apk,另一种是expo客户端.这是繁琐的流程.
I am facing a problem, when I am running an app through expo client app, PushNotifications works. But if I am building a standalone .apk, I need to install expo client, in order to get pushtoken. And, when expo client is not turned on, I cannot get pushtoken. So my customer needs to install 2 apps. One is mine, built standalone .apk, and other is expo client. It is tedious flow..
推荐答案
我能够修复项目中的expo push通知.这是我自己的错. 问题是,即使文档也提供了解决方案: 因此,我使用Firebase创建了一个帐户,然后附加了新项目. 然后我运行以下命令:
I was able to fix expo push notifications in my project. It was my own fault. The problem was this, even documentation provides solution: So I created an account with Firebase, then I attached new project. Then I ran this command:
expo push:android:upload --api-key <Server key>
您可以从此部分获取服务器密钥:
You can get server key from this section:
它看起来像这样:
XXXSdasx665:APA91bFL2342342342342342342342RxDAUbCOP0IL32etVueLhnLtoFErsqHBhjW-SRPSZGdU18BBIltUx7Wm234234234sxdxzcasdSElRyTEdMR7vmLJHgVvbOGx-0-SWDasdzxzxzx
这帮助我解决了遇到的问题.希望它也会对某人有所帮助.
This helped me to fix the issue I was having. Hopes it will help someone too.
这是一个app.json文件:
This is an app.json file:
{
"expo": {
"name": "workero",
"slug": "workero",
"privacy": "public",
"sdkVersion": "36.0.0",
"platforms": ["android"],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.workero.apper",
"googleServicesFile": "./google-services.json"
}
}
}
这篇关于Expo Android应用程式,PushNotifications无法在独立的APK中运作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!