【发布时间】:2020-04-13 18:26:11
【问题描述】:
我使用每小时重复一次的通知,具有不同的 id 和 channel ,但我只收到了第一个 evert time 和其他被阻止的,有时只有 lastone。
这是我的通知功能
Future<void> _scheduleNotification(id,duration,channelname,channelid,soundandroid,soundios,message,title) async {
var vibrationPattern = Int64List(4);
vibrationPattern[0] = 0;
vibrationPattern[1] = 1000;
vibrationPattern[2] = 5000;
vibrationPattern[3] = 2000;
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
channelid,
channelname,
'your other channel description',
icon: '@mipmap/ic_launcher',
importance: Importance.Max,
priority: Priority.High,
ongoing: true,
autoCancel: false,
sound: RawResourceAndroidNotificationSound(soundandroid),
largeIcon: DrawableResourceAndroidBitmap('@mipmap/ic_launcher'),
vibrationPattern: vibrationPattern,
enableLights: true,
color: const Color.fromARGB(255, 255, 0, 0),
ledColor: const Color.fromARGB(255, 255, 0, 0),
ledOnMs: 1000,
ledOffMs: 500);
var iOSPlatformChannelSpecifics =
IOSNotificationDetails(sound:soundios);
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.periodicallyShow(
id,
title,
message,
RepeatInterval.Hourly,
platformChannelSpecifics,
);
}
我调用这个函数来执行
Future<void> smartnotificationcall(channelname,id)
async{
if(channelname=="clean"){ Duration(seconds:5); return _scheduleNotification(1,20,'clean',"clean","clean","clean.wav",'test','test');}
if(channelname=="sport"){ Duration(seconds:20); return _scheduleNotification(2,30,"sport","sport","sport","sport.wav",'test','test');}
if(channelname=="eat"){ Duration(seconds:40); return _scheduleNotification(3,30,"eat","eat","eat","eat.wav",'test','test');}
if(channelname=="getout"){ Duration(seconds:50); return _scheduleNotification(4,30,"getout","getout","getout","getout.wav",'test','test');
}
}
【问题讨论】:
标签: flutter dart notifications dart-pub