我在
Android应用中使用Firebase作为我们的消息服务.我对Firebase进行了相当多的研究,我理解
whether the app if running in the foreground or now will change the type of data received in the onMessageReceived method.
我想要完成的是解析来自Remotemessage的传入数据,并根据自定义标记执行与它不同的操作. IE,如果数据映射包含一个名为“My_Custom_Tag”的字段,我想完全覆盖弹出的标准firebase消息并编写一个自定义消息.
问题是,当应用程序在后台运行时,我放入onMessageReceived的任何代码都不会被触发.当应用程序在前台运行时,它可以正常工作,但如果应用程序在后台,则无法检测/接收任何内容.
以下是一些示例代码:
@Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Map<String,String> aMap = remoteMessage.getData(); //Custom object here for easier parsing PushNotificationsPojo pojo = this.convertResponseToPojo(aMap); if(pojo == null){ passToFirebase(remoteMessage); return; } if(pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_CHAT_MESSAGE)) { createCustomNotification1(pojo); } else if (pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_SOME_OTHER_MESSAGE)){ createCustomNotification2(pojo); } else if (pojo.getData().getCustomTag().equals(PushNotificationsPojo.ID_TAG_STUFF_AND_WHATNOT)) { createCustomNotification3(pojo); } else { passToFirebase(remoteMessage); } }
我的问题是,如何编辑MyFirebaseMessagingService以便我可以检查传入的数据,确定标记信息,并决定将其传递给firebase,以便它可以使用标准处理或不将其传递给firebase并编写我的我的应用程序在后台运行时,我自己的自定义显示通知?
谢谢大家!
PS,Firebase-Dungeon-Master Frank van Puffelen有什么机会有想法吗?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。