From 59e5301ffe392b3069e1a28ed3093a4e3312f783 Mon Sep 17 00:00:00 2001 From: Javier Lecuona Date: Thu, 10 May 2018 23:54:56 -0300 Subject: [PATCH 1/4] Implemented daily notifications with time fixed bad time constructor Fixed param name, suppresed warning Better notification body --- .../FlutterLocalNotificationsPlugin.java | 57 +++++++++++-------- .../models/NotificationDetails.java | 7 +++ .../models/Time.java | 21 +++++++ example/lib/main.dart | 19 +++++++ lib/flutter_local_notifications.dart | 31 ++++++++++ 5 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 android/src/main/java/com/dexterous/flutterlocalnotifications/models/Time.java diff --git a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index 2baff468a..f380c0a28 100644 --- a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -20,6 +20,7 @@ import android.text.Spanned; import com.dexterous.flutterlocalnotifications.models.NotificationDetails; +import com.dexterous.flutterlocalnotifications.models.Time; import com.dexterous.flutterlocalnotifications.models.styles.BigTextStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.DefaultStyleInformation; import com.dexterous.flutterlocalnotifications.models.styles.InboxStyleInformation; @@ -32,6 +33,7 @@ import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Calendar; import java.util.Iterator; import java.util.Map; @@ -170,32 +172,39 @@ private static void repeatNotification(Context context, NotificationDetails noti PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationDetails.id, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = getAlarmManager(context); - long startTimeMilliseconds = notificationDetails.calledAt; - long repeatInterval = 0; - switch(notificationDetails.repeatInterval) { - case EveryMinute: - repeatInterval = 60000; - break; - case Hourly: - repeatInterval = 60000 * 60; - break; - case Daily: - repeatInterval = 60000 * 60 * 24; - break; - case Weekly: - repeatInterval = 60000 * 60 * 24 * 7; - break; - default: - break; - } + if (notificationDetails.repeatTime != null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.set(Calendar.HOUR_OF_DAY, notificationDetails.repeatTime.hour); + calendar.set(Calendar.MINUTE, notificationDetails.repeatTime.minute); + calendar.set(Calendar.SECOND, notificationDetails.repeatTime.second); + alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); + } else { + long startTimeMilliseconds = notificationDetails.calledAt; + long repeatInterval = 0; + switch(notificationDetails.repeatInterval) { + case EveryMinute: + repeatInterval = 60000; + break; + case Hourly: + repeatInterval = 60000 * 60; + break; + case Daily: + repeatInterval = 60000 * 60 * 24; + break; + case Weekly: + repeatInterval = 60000 * 60 * 24 * 7; + break; + default: + break; + } - long currentTime = System.currentTimeMillis(); - while(startTimeMilliseconds < currentTime) { - startTimeMilliseconds += repeatInterval; + long currentTime = System.currentTimeMillis(); + while(startTimeMilliseconds < currentTime) { + startTimeMilliseconds += repeatInterval; + } + alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTimeMilliseconds, repeatInterval, pendingIntent); } - - - alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, startTimeMilliseconds, repeatInterval, pendingIntent); if (updateScheduledNotificationsCache) { ArrayList scheduledNotifications = loadScheduledNotifications(context); scheduledNotifications.add(notificationDetails); diff --git a/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java b/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java index 4995fd918..fd024488e 100644 --- a/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java +++ b/android/src/main/java/com/dexterous/flutterlocalnotifications/models/NotificationDetails.java @@ -20,6 +20,7 @@ public class NotificationDetails { private static final String MILLISECONDS_SINCE_EPOCH = "millisecondsSinceEpoch"; private static final String CALLED_AT = "calledAt"; private static final String REPEAT_INTERVAL = "repeatInterval"; + private static final String REPEAT_TIME = "repeatTime"; private static final String PLATFORM_SPECIFICS = "platformSpecifics"; private static final String AUTO_CANCEL = "autoCancel"; private static final String ONGOING = "ongoing"; @@ -65,6 +66,7 @@ public class NotificationDetails { public NotificationStyle style; public StyleInformation styleInformation; public RepeatInterval repeatInterval; + public Time repeatTime; public Long millisecondsSinceEpoch; public Long calledAt; public String payload; @@ -92,6 +94,11 @@ public static NotificationDetails from(Map arguments) { if(arguments.containsKey(REPEAT_INTERVAL)) { notificationDetails.repeatInterval = RepeatInterval.values()[(Integer)arguments.get(REPEAT_INTERVAL)]; } + if (arguments.containsKey(REPEAT_TIME)) { + @SuppressWarnings("unchecked") + Map repeatTimeParams = (Map)arguments.get(REPEAT_TIME); + notificationDetails.repeatTime = Time.from(repeatTimeParams); + } @SuppressWarnings("unchecked") Map platformChannelSpecifics = (Map) arguments.get(PLATFORM_SPECIFICS); if (platformChannelSpecifics != null) { diff --git a/android/src/main/java/com/dexterous/flutterlocalnotifications/models/Time.java b/android/src/main/java/com/dexterous/flutterlocalnotifications/models/Time.java new file mode 100644 index 000000000..8aeea314f --- /dev/null +++ b/android/src/main/java/com/dexterous/flutterlocalnotifications/models/Time.java @@ -0,0 +1,21 @@ +package com.dexterous.flutterlocalnotifications.models; + +import java.util.Map; + +public class Time { + private static final String HOUR = "hour"; + private static final String MINUTE = "minute"; + private static final String SECOND = "second"; + + public Integer hour = 0; + public Integer minute = 0; + public Integer second = 0; + + public static Time from(Map arguments) { + Time time = new Time(); + time.hour = (Integer) arguments.get(HOUR); + time.minute = (Integer) arguments.get(MINUTE); + time.second = (Integer) arguments.get(SECOND); + return time; + } +} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index ee24c037d..65ad3e7ad 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -86,6 +86,13 @@ class _MyAppState extends State { onPressed: () async { await _repeatNotification(); })), + new Padding( + padding: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 8.0), + child: new RaisedButton( + child: new Text('Repeat notification every day at 10:00:00 am (aprox)'), + onPressed: () async { + await _repeatDailyAtTime(new Time(10, 0, 0)); + })), new Padding( padding: new EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 8.0), child: new RaisedButton( @@ -328,6 +335,18 @@ class _MyAppState extends State { await flutterLocalNotificationsPlugin.periodicallyShow(0, 'repeating title', 'repeating body', RepeatInterval.EveryMinute, platformChannelSpecifics); } + + Future _repeatDailyAtTime(Time time) async { + NotificationDetailsAndroid androidPlatformChannelSpecifics = + new NotificationDetailsAndroid('repeatDailyAtTime channel id', + 'repeatDailyAtTime channel name', 'repeatDailyAtTime description'); + NotificationDetailsIOS iOSPlatformChannelSpecifics = + new NotificationDetailsIOS(); + NotificationDetails platformChannelSpecifics = new NotificationDetails( + androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); + await flutterLocalNotificationsPlugin.showDailyAtTime(0, 'repeatDailyAtTime title', + 'It\'s ${time.hour}:${time.minute}:${time.second} approximately' , time, platformChannelSpecifics); + } } class SecondScreen extends StatefulWidget { diff --git a/lib/flutter_local_notifications.dart b/lib/flutter_local_notifications.dart index 92fcd8b06..3599bf4a5 100644 --- a/lib/flutter_local_notifications.dart +++ b/lib/flutter_local_notifications.dart @@ -10,6 +10,20 @@ typedef Future MessageHandler(String message); /// The available intervals for periodically showing notifications enum RepeatInterval { EveryMinute, Hourly, Daily, Weekly } +class Time { + final int hour; + final int minute; + final int second; + + Time([this.hour = 0, this.minute = 0, this.second = 0]); + + Map get serialized => { + "hour": hour, + "minute": minute, + "second": second, + }; +} + class FlutterLocalNotificationsPlugin { factory FlutterLocalNotificationsPlugin() => _instance; @@ -100,6 +114,23 @@ class FlutterLocalNotificationsPlugin { }); } + Future showDailyAtTime(int id, String title, String body, + Time notificationTime, NotificationDetails notificationDetails, + {String payload}) async { + Map serializedPlatformSpecifics = + _retrievePlatformSpecificNotificationDetails(notificationDetails); + await _channel.invokeMethod('periodicallyShow', { + 'id': id, + 'title': title, + 'body': body, + 'calledAt': new DateTime.now().millisecondsSinceEpoch, + 'repeatInterval': RepeatInterval.Daily.index, + 'repeatTime': notificationTime.serialized, + 'platformSpecifics': serializedPlatformSpecifics, + 'payload': payload ?? '' + }); + } + Map _retrievePlatformSpecificNotificationDetails( NotificationDetails notificationDetails) { Map serializedPlatformSpecifics; From a62bd8f6b445864a896673dcf4c5c980e463bee3 Mon Sep 17 00:00:00 2001 From: Javier Lecuona Date: Fri, 11 May 2018 03:57:40 -0300 Subject: [PATCH 2/4] Added support for IOS --- ios/Classes/FlutterLocalNotificationsPlugin.m | 51 ++++++++++++++++--- ios/Classes/NotificationTime.h | 7 +++ ios/Classes/NotificationTime.m | 5 ++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 ios/Classes/NotificationTime.h create mode 100644 ios/Classes/NotificationTime.m diff --git a/ios/Classes/FlutterLocalNotificationsPlugin.m b/ios/Classes/FlutterLocalNotificationsPlugin.m index 54d8e9057..e2c93fa50 100644 --- a/ios/Classes/FlutterLocalNotificationsPlugin.m +++ b/ios/Classes/FlutterLocalNotificationsPlugin.m @@ -1,4 +1,5 @@ #import "FlutterLocalNotificationsPlugin.h" +#import "NotificationTime.h" static bool appResumingFromBackground; @@ -29,6 +30,10 @@ @implementation FlutterLocalNotificationsPlugin NSString *const PRESENT_BADGE = @"presentBadge"; NSString *const MILLISECONDS_SINCE_EPOCH = @"millisecondsSinceEpoch"; NSString *const REPEAT_INTERVAL = @"repeatInterval"; +NSString *const REPEAT_TIME = @"repeatTime"; +NSString *const HOUR = @"hour"; +NSString *const MINUTE = @"minute"; +NSString *const SECOND = @"second"; NSString *const NOTIFICATION_ID = @"NotificationId"; NSString *const PAYLOAD = @"payload"; @@ -149,15 +154,29 @@ - (void)showNotification:(FlutterMethodCall * _Nonnull)call result:(FlutterResul } NSNumber *secondsSinceEpoch; NSNumber *repeatInterval; + NotificationTime *repeatTime; if([SCHEDULE_METHOD isEqualToString:call.method]) { secondsSinceEpoch = @([call.arguments[MILLISECONDS_SINCE_EPOCH] integerValue] / 1000); } else if([PERIODICALLY_SHOW_METHOD isEqualToString:call.method]) { + if (call.arguments[REPEAT_TIME] != [NSNull null]) { + NSDictionary *timeArguments = (NSDictionary *) call.arguments[REPEAT_TIME]; + repeatTime = [[NotificationTime alloc] init]; + if (timeArguments[HOUR] != [NSNull null]) { + repeatTime.hour = @([timeArguments[HOUR] integerValue]); + } + if (timeArguments[MINUTE] != [NSNull null]) { + repeatTime.minute = @([timeArguments[MINUTE] integerValue]); + } + if (timeArguments[SECOND] != [NSNull null]) { + repeatTime.second = @([timeArguments[SECOND] integerValue]); + } + } repeatInterval = @([call.arguments[REPEAT_INTERVAL] integerValue]); } if(@available(iOS 10.0, *)) { - [self showUserNotification:id title:title body:body secondsSinceEpoch:secondsSinceEpoch repeatInterval:repeatInterval presentAlert:presentAlert presentSound:presentSound presentBadge:presentBadge sound:sound payload:payload]; + [self showUserNotification:id title:title body:body secondsSinceEpoch:secondsSinceEpoch repeatInterval:repeatInterval repeatTime:repeatTime presentAlert:presentAlert presentSound:presentSound presentBadge:presentBadge sound:sound payload:payload]; } else { - [self showLocalNotification:id title:title body:body secondsSinceEpoch:secondsSinceEpoch repeatInterval:repeatInterval presentAlert:presentAlert presentSound:presentSound presentBadge:presentBadge sound:sound payload:payload]; + [self showLocalNotification:id title:title body:body secondsSinceEpoch:secondsSinceEpoch repeatInterval:repeatInterval repeatTime:repeatTime presentAlert:presentAlert presentSound:presentSound presentBadge:presentBadge sound:sound payload:payload]; } result(nil); } @@ -215,7 +234,7 @@ - (NSDictionary*)buildUserDict:(NSNumber *)id title:(NSString *)title presentAle return userDict; } -- (void) showUserNotification:(NSNumber *)id title:(NSString *)title body:(NSString *)body secondsSinceEpoch:(NSNumber *)secondsSinceEpoch repeatInterval:(NSNumber *)repeatInterval presentAlert:(bool)presentAlert presentSound:(bool)presentSound presentBadge:(bool)presentBadge sound:(NSString*)sound payload:(NSString *)payload NS_AVAILABLE_IOS(10.0) { +- (void) showUserNotification:(NSNumber *)id title:(NSString *)title body:(NSString *)body secondsSinceEpoch:(NSNumber *)secondsSinceEpoch repeatInterval:(NSNumber *)repeatInterval repeatTime:(NotificationTime *)repeatTime presentAlert:(bool)presentAlert presentSound:(bool)presentSound presentBadge:(bool)presentBadge sound:(NSString*)sound payload:(NSString *)payload NS_AVAILABLE_IOS(10.0) { UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init]; UNNotificationTrigger *trigger; content.title = title; @@ -248,8 +267,16 @@ - (void) showUserNotification:(NSNumber *)id title:(NSString *)title body:(NSStr } repeats = YES; } - trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval - repeats:repeats]; + if (repeatTime != nil) { + NSDateComponents *dateComponent = [[NSDateComponents alloc] init]; + [dateComponent setHour:[repeatTime.hour integerValue]]; + [dateComponent setMinute:[repeatTime.minute integerValue]]; + [dateComponent setSecond:[repeatTime.second integerValue]]; + trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponent repeats: repeats]; + } else { + trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval + repeats:repeats]; + } } else { NSDate *date = [NSDate dateWithTimeIntervalSince1970:[secondsSinceEpoch integerValue]]; NSCalendar *currentCalendar = [NSCalendar currentCalendar]; @@ -272,7 +299,7 @@ - (void) showUserNotification:(NSNumber *)id title:(NSString *)title body:(NSStr } -- (void) showLocalNotification:(NSNumber *)id title:(NSString *)title body:(NSString *)body secondsSinceEpoch:(NSNumber *)secondsSinceEpoch repeatInterval:(NSNumber *)repeatInterval presentAlert:(bool)presentAlert presentSound:(bool)presentSound presentBadge:(bool)presentBadge sound:(NSString*)sound payload:(NSString *)payload { +- (void) showLocalNotification:(NSNumber *)id title:(NSString *)title body:(NSString *)body secondsSinceEpoch:(NSNumber *)secondsSinceEpoch repeatInterval:(NSNumber *)repeatInterval repeatTime:(NotificationTime *)repeatTime presentAlert:(bool)presentAlert presentSound:(bool)presentSound presentBadge:(bool)presentBadge sound:(NSString*)sound payload:(NSString *)payload { UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.alertBody = body; if(@available(iOS 8.2, *)) { @@ -310,7 +337,17 @@ - (void) showLocalNotification:(NSNumber *)id title:(NSString *)title body:(NSSt notification.repeatInterval = NSCalendarUnitWeekOfYear; break; } - notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval]; + if (repeatTime != nil) { + NSDate *now = [NSDate date]; + NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian]; + NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now]; + [components setHour:[repeatTime.hour integerValue]]; + [components setMinute:[repeatTime.minute integerValue]]; + [components setSecond:[repeatTime.second integerValue]]; + notification.fireDate = [calendar dateFromComponents:components]; + } else { + notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval]; + } [[UIApplication sharedApplication] scheduleLocalNotification:notification]; return; } diff --git a/ios/Classes/NotificationTime.h b/ios/Classes/NotificationTime.h new file mode 100644 index 000000000..0451cc788 --- /dev/null +++ b/ios/Classes/NotificationTime.h @@ -0,0 +1,7 @@ +#import + +@interface NotificationTime : NSObject + @property(nonatomic, strong) NSNumber *hour; + @property(nonatomic, strong) NSNumber *minute; + @property(nonatomic, strong) NSNumber *second; +@end \ No newline at end of file diff --git a/ios/Classes/NotificationTime.m b/ios/Classes/NotificationTime.m new file mode 100644 index 000000000..fefa91f80 --- /dev/null +++ b/ios/Classes/NotificationTime.m @@ -0,0 +1,5 @@ +#import "NotificationTime.h" + +@implementation NotificationTime + +@end \ No newline at end of file From 1b784e559cf475409960a00d72ddb2f849f8121a Mon Sep 17 00:00:00 2001 From: Javier Lecuona Date: Fri, 11 May 2018 04:26:03 -0300 Subject: [PATCH 3/4] Asserts and toMap changes to Time class Added support for IOS --- lib/flutter_local_notifications.dart | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/flutter_local_notifications.dart b/lib/flutter_local_notifications.dart index 3599bf4a5..8273c6ddc 100644 --- a/lib/flutter_local_notifications.dart +++ b/lib/flutter_local_notifications.dart @@ -15,13 +15,19 @@ class Time { final int minute; final int second; - Time([this.hour = 0, this.minute = 0, this.second = 0]); + Time([this.hour = 0, this.minute = 0, this.second = 0]) { + assert(this.hour >= 0 && this.hour < 24); + assert(this.minute >= 0 && this.minute < 60); + assert(this.second >= 0 && this.second < 60); + } - Map get serialized => { - "hour": hour, - "minute": minute, - "second": second, - }; + Map toMap() { + return { + "hour": hour, + "minute": minute, + "second": second, + }; + } } class FlutterLocalNotificationsPlugin { @@ -125,7 +131,7 @@ class FlutterLocalNotificationsPlugin { 'body': body, 'calledAt': new DateTime.now().millisecondsSinceEpoch, 'repeatInterval': RepeatInterval.Daily.index, - 'repeatTime': notificationTime.serialized, + 'repeatTime': notificationTime.toMap(), 'platformSpecifics': serializedPlatformSpecifics, 'payload': payload ?? '' }); @@ -156,4 +162,4 @@ class FlutterLocalNotificationsPlugin { Future _handleMethod(MethodCall call) { return onSelectNotification(call.arguments); } -} +} \ No newline at end of file From 2d691fde2bcfe05ac9ef3c1948942e590f16a4a0 Mon Sep 17 00:00:00 2001 From: Javier Lecuona Date: Mon, 14 May 2018 21:13:51 -0300 Subject: [PATCH 4/4] Added showDailyAtTime channel method name --- .../FlutterLocalNotificationsPlugin.java | 8 ++++++++ ios/Classes/FlutterLocalNotificationsPlugin.m | 5 +++-- lib/flutter_local_notifications.dart | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index f380c0a28..22d5a8a64 100644 --- a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -56,6 +56,7 @@ public class FlutterLocalNotificationsPlugin implements MethodCallHandler, Plugi private static final String CANCEL_ALL_METHOD = "cancelAll"; private static final String SCHEDULE_METHOD = "schedule"; private static final String PERIODICALLY_SHOW_METHOD = "periodicallyShow"; + private static final String SHOW_DAILY_AT_TIME = "showDailyAtTime"; private static final String METHOD_CHANNEL = "dexterous.com/flutter/local_notifications"; private static final String PAYLOAD = "payload"; public static String NOTIFICATION_ID = "notification_id"; @@ -413,6 +414,13 @@ public void onMethodCall(MethodCall call, Result result) { result.success(null); break; } + case SHOW_DAILY_AT_TIME: { + Map arguments = call.arguments(); + NotificationDetails notificationDetails = NotificationDetails.from(arguments); + repeatNotification(registrar.context(), notificationDetails, true); + result.success(null); + break; + } case CANCEL_METHOD: Integer id = call.arguments(); cancelNotification(id); diff --git a/ios/Classes/FlutterLocalNotificationsPlugin.m b/ios/Classes/FlutterLocalNotificationsPlugin.m index e2c93fa50..a0f7ee686 100644 --- a/ios/Classes/FlutterLocalNotificationsPlugin.m +++ b/ios/Classes/FlutterLocalNotificationsPlugin.m @@ -10,6 +10,7 @@ @implementation FlutterLocalNotificationsPlugin NSString *const SHOW_METHOD = @"show"; NSString *const SCHEDULE_METHOD = @"schedule"; NSString *const PERIODICALLY_SHOW_METHOD = @"periodicallyShow"; +NSString *const SHOW_DAILY_AT_TIME_METHOD = @"showDailyAtTime"; NSString *const CANCEL_METHOD = @"cancel"; NSString *const CANCEL_ALL_METHOD = @"cancelAll"; NSString *const CHANNEL = @"dexterous.com/flutter/local_notifications"; @@ -157,7 +158,7 @@ - (void)showNotification:(FlutterMethodCall * _Nonnull)call result:(FlutterResul NotificationTime *repeatTime; if([SCHEDULE_METHOD isEqualToString:call.method]) { secondsSinceEpoch = @([call.arguments[MILLISECONDS_SINCE_EPOCH] integerValue] / 1000); - } else if([PERIODICALLY_SHOW_METHOD isEqualToString:call.method]) { + } else if([PERIODICALLY_SHOW_METHOD isEqualToString:call.method] || [SHOW_DAILY_AT_TIME_METHOD isEqualToString:call.method]) { if (call.arguments[REPEAT_TIME] != [NSNull null]) { NSDictionary *timeArguments = (NSDictionary *) call.arguments[REPEAT_TIME]; repeatTime = [[NotificationTime alloc] init]; @@ -217,7 +218,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if([INITIALIZE_METHOD isEqualToString:call.method]) { [self initialize:call result:result]; - } else if ([SHOW_METHOD isEqualToString:call.method] || [SCHEDULE_METHOD isEqualToString:call.method] || [PERIODICALLY_SHOW_METHOD isEqualToString:call.method]) { + } else if ([SHOW_METHOD isEqualToString:call.method] || [SCHEDULE_METHOD isEqualToString:call.method] || [PERIODICALLY_SHOW_METHOD isEqualToString:call.method] || [SHOW_DAILY_AT_TIME_METHOD isEqualToString:call.method]) { [self showNotification:call result:result]; } else if([CANCEL_METHOD isEqualToString:call.method]) { [self cancelNotification:call result:result]; diff --git a/lib/flutter_local_notifications.dart b/lib/flutter_local_notifications.dart index 8273c6ddc..d2f2a6e15 100644 --- a/lib/flutter_local_notifications.dart +++ b/lib/flutter_local_notifications.dart @@ -125,7 +125,7 @@ class FlutterLocalNotificationsPlugin { {String payload}) async { Map serializedPlatformSpecifics = _retrievePlatformSpecificNotificationDetails(notificationDetails); - await _channel.invokeMethod('periodicallyShow', { + await _channel.invokeMethod('showDailyAtTime', { 'id': id, 'title': title, 'body': body,