如何在没有Firebase的情况下使用Flutter并使用自己的自定义后端设置推送通知 [英] How to setup Push Notifications with Flutter without Firebase and with own custom backend

查看:162
本文介绍了如何在没有Firebase的情况下使用Flutter并使用自己的自定义后端设置推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发带有react native的应用程序,现在我正在考虑使用Flutter重建应用程序.在开始重建之前,我正在研究Flutter的功能,并查看它是否适合我们的项目.我在推送通知插件上苦苦挣扎.关于使用Firebase Cloud Messaging通过应用程序中的Firebase Messaging插件将推送通知发送到Flutter应用程序的信息,在线上有很多信息,但是我没有找到任何关于使用自己的自定义后端设置Push Notifications的好文章.

I have been developing an App with react native and i am now looking at rebuilding the App using Flutter. Before i start on a rebuild i was researching the functionality of Flutter and seeing if it would be right for our project. I have struggled a bit on plugins for Push Notifications. There is quite a bit of information online for using the Firebase Cloud Messaging to send push notifications to a Flutter App using the Firebase Messaging plugin in the App but i have not found any good articles on setting up Push notifications with your own custom back end.

我们已经有一个自定义的Node JS后端,该后端可以向Apple和Google的Push消息传递系统提供Push通知,因此我不想开始依赖Firebase云消息传递,而这只会使我们的系统复杂化.

We already have a custom Node JS backend that serves Push notifications to apple and googles push messaging system so i don't want to start to rely on firebase cloud messaging which will just complicate our systems.

有人知道是否可以以及如何使用Flutter应用程序设置推送通知,但使用您自己的自定义Node JS后端而不使用Firebase云消息传递吗?

Does anyone know if and how Push notifications can be setup with a Flutter app but using your own custom Node JS backend and not using firebase cloud messaging?

推荐答案

首先回答要问的问题.

  1. 您知道推送通知在整体上如何工作吗?
  2. 以及后端如何通知移动设备某些更改?

从firebase开始的工作是这样的:

To start with firebase works like this:

当后端向Firebase服务器发送推送通知时,firebase在XMPP服务器上发送一条消息,该消息通过Google Play服务进行主动连接,而苹果APNs服务器也是如此.

When backend fires push notification to the firebase server firebase sends a message on the XMPP server which is actively connected via google play services and the same goes for the apple APNs server.

现在,当Google Play服务收到此消息时,它将包含捆绑包ID和用于标识要发送哪个应用的信息.这就是为什么我们在android应用清单文件中注册广播.只需考虑一下广播,就不会在没有任何发送广播调用的情况下调用广播,如果您不调用该函数,那么谁会呢?

Now when google play service will have this message it will contain the bundle id and something to identify which app to send. And that's why we register broadcast in android app manifest file. Just think about it broadcast do not get called without any send broadcast invoke and if you're not invoking the function then who does?

该部分已经由Google Play服务处理,以启动您的广播并让您知道收到了哪些推送通知.

That part has been handled by the google play service to fire up your broadcast and let you know what push notifications you have received.

所以我的回答是不",不要使用后端触发推送通知,因为您随后需要使用自己的XMPP服务器,并让您的应用以高优先级连接,而这在没有显示正在执行的通知的情况下是当前无法实现的

so my answer will be no do not use your backend to fire push notification because you need to then use your own XMPP server and let your app connected with a high priority which is currently impossible without showing the notification that you're doing something in the background (i.e. at least for android, ios will not remain in the background after 15min but you can extend by overriding some methods but still if apple reports you, you will not get chance to make app production ready.)

因此,对于android来说,无论是Google服务还是其他服务(例如说为和示例),天蓝色的通知仍然需要GCM令牌和密钥,因此您可能要重新考虑一下目前的想法.

So for android either it's google services or any other services like say for and example azure notification still needs GCM token and key so you might want to reconsider what you are thinking at the moment.

这篇关于如何在没有Firebase的情况下使用Flutter并使用自己的自定义后端设置推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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