![](/img/trans.png)
[英]Is there a way to skip a recurring notification using flutter_local_notifications?
[英]Schedule notification using flutter_local_notifications
我正在使用flutter_local_notifications
插件向我的用戶發送通知。 但我需要安排通知。 所以我使用zonedSchedule()
來做到這一點。 問題是zonedSchedule()
需要 TZDateTime,所以我需要將 DateTime 轉換為 TZDateTime。 我看到了這個問題,但它對我不起作用。 我只需要獲取用戶的Location
並傳遞給TZDateTime.from(dateTime,location)
。 我怎樣才能得到這個位置?
提前致謝。
我剛剛問過這個問題,但我已經有了答案。 對於那些對Location
有問題的人,您可以使用tz.getLocation(await FlutterNativeTimezone.getLocalTimezone())
來獲取TZDateTime.from(dateTime,location)
的location
參數。
PS.:記得導入: import 'package:timezone/data/latest.dart' as tz;
並將import 'package:timezone/timezone.dart' as tz;
.
此外,您必須初始化tz
:
tz.initializeTimeZones();
tz.setLocalLocation(tz.getLocation(await FlutterNativeTimezone.getLocalTimezone()));
就是這樣,我希望它有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.