Meerkat 버전 pc를 바꾸면서 5월 18일날 설치
showNotification2() async {
tz.initializeTimeZones();
var androidDetails = const AndroidNotificationDetails(
'유니크한 알림 ID',
'알림종류 설명',
priority: Priority.high,
importance: Importance.max,
color: Color.fromARGB(255, 255, 0, 0),
);
var iosDetails = const DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true,
);
try {
await notifications.zonedSchedule(
2,
'제목2',
'3초 후에 나타나는 알림',
tz.TZDateTime.now(tz.local).add(Duration(seconds: 3)),
NotificationDetails(android: androidDetails, iOS: iosDetails),
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
matchDateTimeComponents: null
);
print("알림 예약됨");
} on PlatformException catch (e) {
print("알림 예약 실패: ${e.message}");
}
}
pubspec.yaml 파일
dependencies:
flutter:
sdk: flutter
http: ^1.3.0
image_picker: ^1.1.2
intl: ^0.20.2
shared_preferences: ^2.5.3
provider: ^6.1.5
flutter_local_notifications: ^19.2.0
timezone: ^0.10.1
기존의
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime
이부분이 오류가 나서 찾아보니 위와 같이 하면 된다고 해서 바꿈
그리고 알람 권한을 줘야한다고해서 그냥 App info에 들어가
Alarms & reminders 를 허용으로 해주고
실행을 했는데
'알림이 예약됨'은 콘솔에 출력되는데
알림이 안뜹니다.
이전 강좌인 바로 알람띄우는건 됩니다.
근데 3초 후에 띄우는게 안됩니다