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..
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:
It will look something like this:
XXXSdasx665:APA91bFL2342342342342342342342RxDAUbCOP0IL32etVueLhnLtoFErsqHBhjW-SRPSZGdU18BBIltUx7Wm234234234sxdxzcasdSElRyTEdMR7vmLJHgVvbOGx-0-SWDasdzxzxzx
This helped me to fix the issue I was having. Hopes it will help someone too.
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"
}
}
}
For anyone else, for listeners in managed workflow make sure to set
"useNextNotificationsApi": true in expo.android in your app.json from the directions here
This issue occurs after SDK 38. You can solve the issue with simple steps. Firebase Cloud Messaging is required for all managed and bare workflow Android apps made with Expo, unless you're still running your app in the Expo client. To set up your Expo Android app to get push notifications using your own FCM credentials. You basically need to create a Firebase account and follow the steps.
If you have not already created a Firebase project for your app, do so now by clicking on Add project in the Firebase Console.
In your new project console, click Add Firebase to your Android app
and follow the setup steps. Make sure that the Android package name
you enter is the same as the value of android.package in your
app.json
.
Download the google-services.json
file and place it in your Expo
app's root directory. In your app.json
, add an
android.googleServicesFile field with the relative path to the
google-services.json
file you just downloaded. If you placed it in
the root directory, this will probably look like
{
"android":{
"googleServicesFile": "./google-services.json",
"useNextNotificationsApi":true,
}
}
"useNextNotificationsApi":true
are also required. Finally, make a new build of your app by running expo build:android
.
After these step you need to push your api key to expo server.
expo push:android:upload --api-key <your-token-here>
, replacing <your-token-here>
with the string you just copied. It will store your
token securely on expo servers, where it will only be accessed when
you send a push notification.This steps will help you push notifications through expo server sdk or through the expo push api ExpoPush Api. (FCM is not enabled in IOS for now.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With