即使没有服务或继承的课程,Firebase通知也可以使用? [英] Firebase notification works even with no service or inherited class?

查看:176
本文介绍了即使没有服务或继承的课程,Firebase通知也可以使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中实现了firebase,使用它的通知服务,而且它的工作,今天决定使用它的键/值功能,但是意识到不管我在我的类中写的是从 FirebaseMessagingService ,没有任何反应。所以我决定删除我的课,作为翻译的目的,我仍然收到通知。因此,我从清单中删除了Firebase消息传递服务,删除了应用缓存并运行了该项目,但仍收到通知!我可以阻止通知的唯一方法是删除gradle中的firebase依赖项。这里发生了什么?

解决方案

Just 阅读文档
$ b

...



好的,让我们开始吧:有三种使用Firebase的通知:通知消息 与通知和数据。系统收到并处理不同的信息。 此处 您可以看到更多有关消息类型的信息(如何构建)。



有这样的处理:

$ ul

  • 通知消息


    • 前景中的应用程序: onMessageReceived 应用程序在后台:系统托盘(系统调度自动通知) - > 有或没有服务实现(也许你的情况,没有代码我不能知道)

    • 数据信息


      • 前台应用程序: onMessageReceived 的实现

      • 后台应用程序: onMessageReceived


      • ul>
      • 前台应用程序: onMessageReceiv
      • 应用程序在后台:系统托盘(通知)和额外的意图(数据)

      • 没有任何代码或通知信息,我不能继续帮助你。直到你提供了一些代码的例子,我只认为你发送了一个通知消息,所以系统自动显示通知,并且没有调用服务的 onMessageReceived

        如果您想控制并决定是否显示通知,只需发送数据消息 ,并在你的 onMessageReceived 实现中,创建一个包含内容和意图的通知,并将它通知给系统(如果你希望显示的话)。

        I implemented firebase into my app to use it's notification service a while back and it worked, and today decided to use it's key/value feature, but realized that no matter what I write in my class inherited from FirebaseMessagingService, nothing happens. So I decided to remove the my class for dubugging purposes, and I still got notifications. So I removed the firebase messaging service from the manifest, deleted the app cache and ran the project, but I still get notifications! The only way I can prevent notifications from coming is to remove the firebase dependency in gradle. What's happening here?

        解决方案

        Just read the documentation.

        ...

        Ok, let's go: there are three kind of "notification" using Firebase: notification messages, data messages and messages with both notification and data. Each is received and handled differently by the system. Here you can see more information about message types (how there are built).

        There are handled like that:

        • Notification message
          • App in foreground: onMessageReceived's implementation
          • App in background: system tray (system dispatch automatically notification) -> with or without service implementation (maybe your case, without code I can't know)
        • Data message
          • App in foreground: onMessageReceived's implementation
          • App in background: onMessageReceived's implementation
        • Message with both notification and data
          • App in foreground: onMessageReceived's implementation
          • App in background: system tray (notification) and in extras of the intent (data)

        But without any code or notification information, I can't continue to help you. Until you provide some code example, I only think that you send a notification message, and so system automatically display a notification and there is no call to the service's onMessageReceived, it's normal.

        If you want to "control" and decide if notification should be shown or not, just send data messages, and in your onMessageReceived implementation, create a notification with content and intent and notify it to the system (if you want it to be shown).

        这篇关于即使没有服务或继承的课程,Firebase通知也可以使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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