Expo push-notifications are not working on Android APK Build

I am trying to send Notifications for the Android App I created with React Native and Expo. The problem is that the Notifications are working when I start my App with Expo Go, but when I am trying to send Notifications with my APK Build, it does not work.

I followed all the steps from this expo guide, but it still does not work and I dont know why. I tried to send the Notifications with my Code and also with this expo push notification tool. In both cases I won`t get any error message and I am not recieving a Notification with my APK build.

I hope you could help me with this.

Thanks in advance

Orchi

Hi Orchi,

If the notifications are working in expo go, but not in an APK, it sounds to me like maybe FCM wasn’t setup, or at least wasn’t setup correctly? Check out the docs here → Push notifications setup - Expo Documentation

For Android, you need to configure Firebase Cloud Messaging (FCM) to get your credentials and set up your Expo project. It is required for all Android apps using Expo SDK (unless you are testing your project in Expo Go).

Hi appflow,

thanks for your reply. Unfortunately FCM was set up with exactly the docs you provided. Also I found out that there are special error codes for the case that FCM is not set up correctly, as you can see here: Send notifications with Expo's Push API - Expo Documentation. I am not recieving any error code, all I get is a “status”: “ok” as you can see in the picture.

I get the following response:

I hope you can help me understanding why it does not work.

Thanks in advance

Orchi

Ah my bad for assuming you hadn’t set up FCM.

When you start your app, do you get asked the native notifications permissions? If not, could you go check in your phone’s settings to see if notifications are somehow disabled for the app? Would you have another phone to try it on just for curiosity?

Yes I am getting asked the notifications permissions and I also checked in my phone’s settings if notifications are activated and they are. I already tested the app on four different Android devices and the notifications are working on all of them when using the Expo Go app but on none of them when using the build.

Sorry if these questions sound obvious, but it’s better to ask

  1. In your app.json, do you have a link to your google-services file under android.googleServicesFile ?
  2. In your google-services file, did you add your api_key under api_key.current_key ?
  3. Are you sure that that key under api_key.current_key matches on google cloud console → Credentials → Android key (Created by Firebase)
  4. In your google cloud console, under Credentials → Android key (the one created by Firebase), is the key unrestricted?

According to the troubleshooting Push notifications troubleshooting & FAQ - Expo Documentation if it works in expo but not in standalone, it’s very likely that 1 part or more of the FCM setup weren’t done or weren’t done correctly. If you’re still lost, I’ll dig deeper

Thank you for asking this questions, I am very happy that you are trying to help me :slight_smile:

  1. Yes, there is a link to my google-services.json file in my app.json
  2. Yes, I added my api_key in the google-services file
  3. Yes, both keys are matching
  4. Yes, the key is unrestricted

Well, I am still lost :smiley:

Hmm damn lol. There is two things you could do, they both take a bit of time but if you’re completely out of options, it might be worth the hassle.

The first one I can think of would be to start a fresh new project. Then create new keys, do all the same steps, just a minimal project whose only goal is to be able to receive a notification. If this works, then it might be worth comparing “the project that works” with “the project that doesn’t work”. If it doesn’t work, then it might be worth posting an issue on expo’s github, maybe you are truly in some bug kind of situation, but I don’t think so mainly bc I’ve set up notifications many times and it does work in an apk.

The second thing you could try is a bit more farfetched. Essentially you want to figure out : is your phone getting the notification, but somehow your phone or something else is blocking them? Is there a native error message, something failing silently, etc. You could try the following : plug your phone via usb, make sure it appears when you do adb devices , then run adb logcat > logs.txt Send yourself 3 notifications (or 5 or whatever, but do it quickly bc there’s hundreds/thousands of logs per second). Then the long part is coming through these logs trying to see if anything stands out, keywords like notification, error, etc. Since you sent it 3 times, if there is an error happening, it will appear 3 times, so that could give you a clue.

I don’t know what else to try :confused: The only ticket I found that is slightly related is this Android 12 not receving expo-notifications correctly · Issue #16678 · expo/expo · GitHub but it’s not your use case bc you’re not getting this error… Btw which android version are you using, which expo SDK and are you managed or bare workflow?

Thanks, I will try these two things out.

I tested the apk on smartphones with android version 12, 10 and 9.
I am using the expo SDK version 48.0.9 and I am managed workflow.