2

I'm using Expo push notifications. Push notifications work fine in Expo Go and for apps on published to the Google Play store. But when I create an APK file and download it directly onto my Android phone, NOT through the Google Play store, the push notifications I send are not received.

Will push notifications only work for apps published to the Google Play store? Or is there a way to receive push notifications for apps downloaded directly onto an Android phone without being published to the Google Play store?

Page COW
  • 515
  • 13
  • 31
  • No, it is not necessary to publish the app on to play store to receive push notifications – Srinath gunnu Sep 10 '21 at 12:41
  • Did you test with -> https://expo.dev/notifications – Michael Bahl Sep 10 '21 at 13:04
  • @MichaelBahl Yes I did. It works in Expo Go and for apps published to the Google Play store. But it will NOT work for apk downloaded directly to the phone. – Page COW Sep 10 '21 at 13:17
  • Did you check the app permission ? – Michael Bahl Sep 10 '21 at 14:40
  • @MichaelBahl What is app permission? Can you respond with that as an answer? I'll checkmark it as the answer if that fixes it. Thank you – Page COW Sep 10 '21 at 15:44
  • Have you set up FCM? If not, please refer to a question I just answered here: https://stackoverflow.com/questions/69140907/react-native-firebase-push-notificatoins-using-expo-permission -- I just set this up a week or so ago for my app so that I could have my app respond to background notifications (you can't do/test that in Expo Go). The instructions require a bit of focus, but if you haven't done it yet, it's definitely the reason why your Expo Go app would work but your Standalone/Managed/APK build wouldn't. – Atmas Sep 11 '21 at 07:59

2 Answers2

1
  1. Depending on your android version and rom you have to open the app setting's (for me long press app icon).

  2. Select settings

  3. Choose notifications

  4. Enable notification for this app

Michael Bahl
  • 2,941
  • 1
  • 13
  • 16
  • This was helpful. It did not fix the problem yet, but it proved there's something wrong with the permission request on APK direct download. The APK app is not requesting permission to send push notifications on the APK direct download for some reason. But it DOES request permission fine in Expo Go and in apps published to the Google or Apple app stores. – Page COW Sep 13 '21 at 13:28
0

I forgot to import { Platform } from 'react-native'.

Also, I needed to upload Android server api key credentials which can be found in Firebase Console in your project settings under Cloud Messaging. Here is how to upload the server api key credentials in the terminal:

expo push:android:upload --api-key <your-token-here>

Documentation can be found here under "Uploading Server Credentials": https://docs.expo.dev/push-notifications/using-fcm/

Page COW
  • 515
  • 13
  • 31