Firebase message not received on emulator

11,606

Solution 1

Does the emulator has Google Play Services installed?

source: https://firebase.google.com/docs/cloud-messaging/android/client#sample-play

Apps that rely on the Play Services SDK should always check the device for a compatible Google Play services APK before accessing Google Play services features. It is recommended to do this in two places: in the main activity's onCreate() method, and in its onResume() method. The check in onCreate() ensures that the app can't be used without a successful check. The check in onResume() ensures that if the user returns to the running app through some other means, such as through the back button, the check is still performed.

If the device doesn't have a compatible version of Google Play services, your app can call GoogleApiAvailability.makeGooglePlayServicesAvailable() to allow users to download Google Play services from the Play Store.

Solution 2

Because emulator doesn't have google api's. So to check notification or message you have to check on a real device which has google services installed in that device.

For Google Services like GCM, use a "Google APIs" (any version) target to receive push notifications or messages from fcm

Share:
11,606
Tapomay
Author by

Tapomay

Updated on June 07, 2022

Comments

  • Tapomay
    Tapomay about 2 years

    I followed the instructions in https://stackoverflow.com/a/38626398/565212 to connect SNS to FCM to an Android app. When deployed to an emulator, the app initializes but does not receive any messages. The same app works correctly on my actual Nexus 6 device and receives messages. Why this difference?

  • user1209216
    user1209216 almost 7 years
    It depends, Google provides system images with or without Google APIS. Newer system images are available with Google APIS only.