Test Notification
parent
36abb7da36
commit
09d5e51377
|
@ -30,6 +30,7 @@ android {
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
coreLibraryDesugaringEnabled true
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class ScannerPageState extends State<ScannerPage> {
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
textStyle: const TextStyle(fontSize: 20)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
loadSettingsFromLocalJSON();
|
loadSettingsFromLocalJSON();
|
||||||
NotificationService().setAllNotifications();
|
NotificationService().showNotification();
|
||||||
},
|
},
|
||||||
child: const Text('Read JSON'),
|
child: const Text('Read JSON'),
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class NotificationService {
|
||||||
Future<void> initNotification() async {
|
Future<void> initNotification() async {
|
||||||
// Android initialization
|
// Android initialization
|
||||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
AndroidInitializationSettings('mipmap/ic_launcher');
|
||||||
|
|
||||||
// ios initialization
|
// ios initialization
|
||||||
const DarwinInitializationSettings initializationSettingsIOS =
|
const DarwinInitializationSettings initializationSettingsIOS =
|
||||||
|
@ -38,6 +38,29 @@ class NotificationService {
|
||||||
print(initialized);
|
print(initialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> showNotification() async {
|
||||||
|
await flutterLocalNotificationsPlugin.show(
|
||||||
|
0,
|
||||||
|
'test',
|
||||||
|
'test',
|
||||||
|
//schedule the notification to show after 2 seconds.
|
||||||
|
const NotificationDetails(
|
||||||
|
// Android details
|
||||||
|
android: AndroidNotificationDetails('main_channel', 'Main Channel',
|
||||||
|
channelDescription: "ashwin",
|
||||||
|
importance: Importance.max,
|
||||||
|
priority: Priority.max),
|
||||||
|
// iOS details
|
||||||
|
iOS: DarwinNotificationDetails(
|
||||||
|
sound: 'default.wav',
|
||||||
|
presentAlert: true,
|
||||||
|
presentBadge: true,
|
||||||
|
presentSound: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> setAllNotifications() async {
|
Future<void> setAllNotifications() async {
|
||||||
List<TZDateTime> moodDates = await getDatesforMood();
|
List<TZDateTime> moodDates = await getDatesforMood();
|
||||||
List<TZDateTime> sleepDates = await getDatesforSleep();
|
List<TZDateTime> sleepDates = await getDatesforSleep();
|
||||||
|
|
Loading…
Reference in New Issue