问题描述
我遇到了一个问题,当我通过 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 推送通知.这是我自己的错.问题是这样的,甚至文档也提供了解决方案:所以我用 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中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!