|
|
|
@ -31,25 +31,27 @@ class LocalNotification {
|
|
|
|
|
_initialize() async {
|
|
|
|
|
try {
|
|
|
|
|
var initializationSettingsAndroid = new AndroidInitializationSettings('app_icon');
|
|
|
|
|
// var initializationSettingsIOS = DarwinInitializationSettings(onDidReceiveLocalNotification: null);
|
|
|
|
|
// var initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
|
|
|
|
|
// await flutterLocalNotificationsPlugin.initialize(
|
|
|
|
|
// initializationSettings,
|
|
|
|
|
// onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) {
|
|
|
|
|
// switch (notificationResponse.notificationResponseType) {
|
|
|
|
|
// case NotificationResponseType.selectedNotification:
|
|
|
|
|
// // selectNotificationStream.add(notificationResponse.payload);
|
|
|
|
|
// break;
|
|
|
|
|
// case NotificationResponseType.selectedNotificationAction:
|
|
|
|
|
// // if (notificationResponse.actionId == navigationActionId) {
|
|
|
|
|
// // selectNotificationStream.add(notificationResponse.payload);
|
|
|
|
|
// // }
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
|
|
|
|
|
// );
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
var initializationSettingsIOS = DarwinInitializationSettings(onDidReceiveLocalNotification: null);
|
|
|
|
|
var initializationSettings = InitializationSettings(android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
|
|
|
|
|
await flutterLocalNotificationsPlugin.initialize(
|
|
|
|
|
initializationSettings,
|
|
|
|
|
onDidReceiveNotificationResponse: (NotificationResponse notificationResponse) {
|
|
|
|
|
switch (notificationResponse.notificationResponseType) {
|
|
|
|
|
case NotificationResponseType.selectedNotification:
|
|
|
|
|
// selectNotificationStream.add(notificationResponse.payload);
|
|
|
|
|
break;
|
|
|
|
|
case NotificationResponseType.selectedNotificationAction:
|
|
|
|
|
// if (notificationResponse.actionId == navigationActionId) {
|
|
|
|
|
// selectNotificationStream.add(notificationResponse.payload);
|
|
|
|
|
// }
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// onDidReceiveBackgroundNotificationResponse: notificationTapBackground,
|
|
|
|
|
);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
print(ex.toString());
|
|
|
|
|
}
|
|
|
|
|
// flutterLocalNotificationsPlugin.initialize(initializationSettings, onDidReceiveNotificationResponse: (NotificationResponse notificationResponse)
|
|
|
|
|
// {
|
|
|
|
|
// switch (notificationResponse.notificationResponseType) {
|
|
|
|
@ -96,15 +98,26 @@ class LocalNotification {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future showNow({@required String title, @required String subtitle, String payload}) {
|
|
|
|
|
// Future.delayed(Duration(seconds: 1)).then((result) async {
|
|
|
|
|
// var androidPlatformChannelSpecifics = AndroidNotificationDetails('com.hmg.local_notification', 'HMG',
|
|
|
|
|
// channelDescription: 'HMG', importance: Importance.max, priority: Priority.high, ticker: 'ticker', vibrationPattern: _vibrationPattern());
|
|
|
|
|
// var iOSPlatformChannelSpecifics = DarwinNotificationDetails();
|
|
|
|
|
// var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics);
|
|
|
|
|
// await flutterLocalNotificationsPlugin.show(_randomNumber(), title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) {
|
|
|
|
|
// print(err);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
Future.delayed(Duration(seconds: 1)).then((result) async {
|
|
|
|
|
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
|
|
|
|
|
'com.hmg.local_notification',
|
|
|
|
|
'HMG',
|
|
|
|
|
channelDescription: 'HMG',
|
|
|
|
|
importance: Importance.max,
|
|
|
|
|
priority: Priority.high,
|
|
|
|
|
ticker: 'ticker',
|
|
|
|
|
vibrationPattern: _vibrationPattern(),
|
|
|
|
|
ongoing: true,
|
|
|
|
|
autoCancel: false,
|
|
|
|
|
usesChronometer: true,
|
|
|
|
|
when: DateTime.now().millisecondsSinceEpoch - 120 * 1000,
|
|
|
|
|
);
|
|
|
|
|
var iOSPlatformChannelSpecifics = DarwinNotificationDetails();
|
|
|
|
|
var platformChannelSpecifics = NotificationDetails(android: androidPlatformChannelSpecifics, iOS: iOSPlatformChannelSpecifics);
|
|
|
|
|
await flutterLocalNotificationsPlugin.show(25613, title, subtitle, platformChannelSpecifics, payload: payload).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future scheduleNotification({@required DateTime scheduledNotificationDateTime, @required String title, @required String description}) async {
|
|
|
|
@ -115,7 +128,7 @@ class LocalNotification {
|
|
|
|
|
vibrationPattern[2] = 5000;
|
|
|
|
|
vibrationPattern[3] = 2000;
|
|
|
|
|
|
|
|
|
|
// var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions',
|
|
|
|
|
// var androidPlatformChannelSpecifics = AndroidNotificationDetails('active-prescriptions', 'ActivePrescriptions',
|
|
|
|
|
// channelDescription: 'ActivePrescriptionsDescription',
|
|
|
|
|
// // icon: 'secondary_icon',
|
|
|
|
|
// sound: RawResourceAndroidNotificationSound('slow_spring_board'),
|
|
|
|
|