Flutter:即使应用已关闭,也推送通知 [英] Flutter: Push notifications even if the app is closed

本文介绍了Flutter:即使应用已关闭,也推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用颤动构建了一个应用程序,就像提醒一样.
即使该应用已关闭,如何向用户显示通知?

I have built an application with flutter that works like a reminder.
How can I display notifications to the user even though the app is closed?

推荐答案

为提醒起见,我建议使用 Flutter本地通知插件.它具有强大的调度API.从本地通知的文档中:

For reminders i would recomend Flutter Local Notifications Plugin. It has a powerful scheduling api. From the documentation of local notification:

安排应在何时出现通知-定期显示 通知(基于时间间隔)-安排要显示的通知 每天在指定时间-安排每周显示一次通知 在指定的日期和时间-当应用程序是前台,后台或终止

Scheduling when notifications should appear - Periodically show a notification (interval-based) - Schedule a notification to be shown daily at a specified time - Schedule a notification to be shown weekly on a specified day and time - Ability to handle when a user has tapped on a notification when the app is the foreground, background or terminated

对于推送通知,您可以使用 Firebase云消息传递 一个信号插件,也可以通过

And for push notification, you can use Firebase Cloud Messaging or one signal plugin or you can implement natively through platform-channels

即使该应用已终止,您也可以根据特定条件触发通知.这可以通过在后台运行飞镖代码来解决.引用官方常见问题解答:

You can also fire notifications according to specific conditions even if the app is terminated. This can be achevied by running dart code in the background. Quoting from the official faq:

我可以在Flutter应用程序的后台运行Dart代码吗?是的你可以 在iOS和Android上的后台进程中运行Dart代码.为了 有关更多信息,请参见中型文章

Can I run Dart code in the background of an Flutter app? Yes, you can run Dart code in a background process on both iOS and Android. For more information, see the Medium article Executing Dart in the Background with Flutter Plugins and Geofencing.

这篇关于Flutter:即使应用已关闭,也推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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