Код: Выделить всё
tz.initializeTimeZones();
final String currentTimeZone = await FlutterTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(currentTimeZone));
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'your_channel_id', 'your_channel_name',
importance: Importance.max, priority: Priority.high, ticker: 'ticker');
var platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics);
var date = tz.TZDateTime.now(tz.local).add(const Duration(seconds: 5));
await flutterLocalNotificationsPlugin.zonedSchedule(
0,
'scheduled title',
'scheduled body',
date,
platformChannelSpecifics,
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle);
< /code>
} < /p>
Это работает, когда приложение находится в фоновом режиме, но оно не работает, если устройство заблокировано. Мне нужен звуковой сигнал, когда устройство заблокировано.
Подробнее здесь: https://stackoverflow.com/questions/795 ... -is-locked