Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase message not received on emulator

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?

like image 808
Tapomay Avatar asked Sep 28 '17 08:09

Tapomay


2 Answers

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.

like image 118
Idanatz Avatar answered Oct 04 '22 02:10

Idanatz


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

like image 42
Mayank Bhatnagar Avatar answered Oct 04 '22 02:10

Mayank Bhatnagar