Firebase通知在Android Emulator中不起作用 [英] Firebase notifications not working in Android Emulator

查看:80
本文介绍了Firebase通知在Android Emulator中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用Firebase发送通知的Android应用.使用我的物理设备(Google Nexus 5,并在其他设备上进行了测试)时,一切都能按预期工作,但是使用模拟器时,我无法收到通知.

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.

平台:Windows Android Studio:带有Google Play服务的2.3.1 39 API:24 模拟器:Nexus 6 API 24,Android 7.0

Platform: Windows Android Studio: 2.3.1 with Google Play Services 39 API: 24 Emulator: Nexus 6 API 24, Android 7.0

有什么主意吗?

推荐答案

您是否尝试过使用不同的仿真器配置,使用具有生成的Firebase实例令牌的Single device选项从Firebase控制台定位仿真器,并验证Firebase的Firebase通知状态邮件标记为完成?当应用程序处于前台状态时,您是否正在发送后台通知?您确定模拟器上可以使用Google Play服务吗?

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:

  1. 记录模拟器的Firebase实例令牌
  2. 在Firebase中导航到您的应用程序的通知页面 控制台
  3. 点击新消息
  4. 添加您的消息文本
  5. 在目标"下,选择单个设备
  6. 将您在第1步中登录的Firebase注册令牌粘贴到文本框中
  7. 确保您的应用在后台运行
  8. 发送消息
  1. Log the emulator’s Firebase instance token
  2. Navigate to the notification page of your app in the Firebase console
  3. Click new message
  4. Add your message text
  5. Under Target, select single device
  6. Paste the Firebase registration token you logged in step 1, into the textbox
  7. Make sure your app is running in the background
  8. Send the message

这篇关于Firebase通知在Android Emulator中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆