问题
I am developing an Android app which uses Firebase to send notifications. Everything works as expected when using my physical device (Google Nexus 5, and also tested on others), but I cannot receive notification when using the emulator.
Platform: Windows Android Studio: 2.3.1 with Google Play Services 39 API: 24 Emulator: Nexus 6 API 24, Android 7.0
Any idea?
回答1:
Have you tried using different emulator configurations, targeting the emulator from the Firebase console using the single device option with the generated Firebase instance token, verifying Firebase notification status for the messages are marked complete? Are you sending a background notification when the app is in the foreground? Are you sure Google Play Services are available on the emulator?
The single device option will probably help you the most when you debug. Repeat these steps as you make small incremental changes to your code:
- Log the emulator’s Firebase instance token
- Navigate to the notification page of your app in the Firebase console
- Click new message
- Add your message text
- Under Target, select single device
- Paste the Firebase registration token you logged in step 1, into the textbox
- Make sure your app is running in the background
- Send the message
来源:https://stackoverflow.com/questions/43562897/firebase-notifications-not-working-in-android-emulator