Notifications 颤振:即使我的应用程序关闭,我如何接收本地通知?

Notifications 颤振:即使我的应用程序关闭,我如何接收本地通知?,notifications,flutter,Notifications,Flutter,我创建了一个每分钟接收信号的颤振应用程序,当我收到新信号时,我会显示本地通知。当应用程序打开时,通知显示良好,但当应用程序关闭时,我没有收到任何通知。我试图补充 <receiver android:name=".notification.NotificationReceiver"> <intent-filter> <action android:name="io.flutter.app.notification.REC

我创建了一个每分钟接收信号的颤振应用程序,当我收到新信号时,我会显示本地通知。当应用程序打开时,通知显示良好,但当应用程序关闭时,我没有收到任何通知。我试图补充

    <receiver android:name=".notification.NotificationReceiver">
        <intent-filter>
            <action android:name="io.flutter.app.notification.RECEIVE"/>
            <action android:name="io.flutter.app.notification.DELETE" />
            <action android:name="io.flutter.app.notification.OPEN" /> 
        </intent-filter>
    </receiver>

对于Android,但它不起作用


有一种方法可以通过颤振来实现这一点?

如果它是本地通知,请尝试从中获取代码片段

Future\u showNotification()异步{
var androidPlatformChannelSpecifics=AndroidNotificationDetails(
“您的频道id”、“您的频道名称”、“您的频道描述”,
重要性:重要性。最大,优先级:优先级。高,股票代码:“股票代码”);
var iOSPlatformChannelSpecifics=ioNotificationDetails();
var platformChannelSpecifics=通知详细信息(
androidPlatformChannelSpecifics、iOSPlatformChannelSpecifics);
等待本地通知。显示(
0,“普通标题”,“普通正文”,平台通道详细信息,
有效载荷:“项目x”);
}

它还可以选择计划通知,并根据单击的通知进行路由。

您可能需要查看推送通知,因为在应用程序不运行的情况下,推送通知可以正常工作。
  Future<void> _showNotification() async {
    var androidPlatformChannelSpecifics = AndroidNotificationDetails(
        'your channel id', 'your channel name', 'your channel description',
        importance: Importance.Max, priority: Priority.High, ticker: 'ticker');
    var iOSPlatformChannelSpecifics = IOSNotificationDetails();
    var platformChannelSpecifics = NotificationDetails(
        androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
    await flutterLocalNotificationsPlugin.show(
        0, 'plain title', 'plain body', platformChannelSpecifics,
        payload: 'item x');
  }