Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS scheduled notification #16

Closed
Filpin011 opened this issue Oct 21, 2020 · 8 comments
Closed

IOS scheduled notification #16

Filpin011 opened this issue Oct 21, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@Filpin011
Copy link

Filpin011 commented Oct 21, 2020

hi, I'm trying to use scheduled notification on iOS, on android all chrono function works well, but on iOS dont work

this is the function that I tried:

Future<void> repeatMinuteNotificationOClock(int id) async { await AwesomeNotifications().createNotification( content: NotificationContent( id: id, channelKey: 'schedule', title: 'Notification at exactly every single minute', body: 'This notification was schedule to repeat at every single minute at clock.', ), schedule: NotificationSchedule( crontabSchedule: CronHelper.instance.minutely(initialSecond: 5))); }

if I schedule with this all work perfectly, but this dont repeat notification:

await AwesomeNotifications().createNotification( content: NotificationContent( id: id, channelKey: "scheduled", title: title, body: 'xClock è tempo di $title', payload: {'uuid': 'uuid-test'}), schedule: NotificationSchedule(initialDateTime: delayed.toUtc()));

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 21, 2020

iOS still in development. But anyway, it will not be possible to make complex schedules on iOS, due the operational system limitations to run background tasks.

IOS does not respect time schedules and runs whatever it thinks it should, when it thinks it should. Sometimes it even executes.

Ill put on README more explanations about it on next releases.

@Filpin011
Copy link
Author

tnx man, but a normal scheduling, like every week? or every day? is possible or not?

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 21, 2020

Depends, and that is the problem.

On iOS, the notification schedule is made before the notification itself beeing created, and only offeres support to a few schedule types:

  • UNTimeIntervalNotificationTrigger: Permits to schedule a notification after a amount of seconds, repeatly or not, but without a initial or even a final date.

  • UNCalendarNotificationTrigger: Permits to schedule a notifcation based on time components and allows to repeats it indefinetly. Similar to cronTab rules, but you can only specify each component with a single value (example: hour=2, minute=0). Its not possible to schedule a notification with two o more values for the same component, as such notifications to play on sunday and saturday, or at 12 am and 6 pm.

If you try to "improve" that limitation, you gonna fall in a serious problem: If you create a new schedule to a notification id already scheduled, you gonna replace the old one. So, if you use random numbers or a subproduct id method to allows you to send the same notification with different IDs, youll fatally gonna falls on "cartesian product" combination, wich can easly produces a huge number of duplicated notifications scheduled on the system (and iOS only supports the maximum local notifcation scheduleds to 64).

  • UNLocationNotificationTrigger: Triggered by location and requires another permissions than normaly offers by notifications to work.

Unfortunely, the only method to receive the notification before displays it is using "willPresent" method, but it only works on foreground. So, its not possible to process correctely the next schedule as soon as it displays. Because of that, schedules on iOS works perfectly only on foreground, but not on background or even when the app is killed.

And also unfortunely, there is no way to create a superclass to extends the default schedules and offers a more powerful and complete solution.

Background process are another problem. They run when they think its ok to do, and almost never respect the schedule parameters. They are two types:

  • Refresh Background: can only run in 5 seconds and "allows you to define a minimum period to update", wich almost never work and doesnt make any sense, because if i could schedule a task to only starts after a certain date, its better to schedule it as fast as possible to ensure the correct execution on the right time.

  • Background task: runs at "God knows when" date and supports to run at maximum in 30 seconds.

If any of above conditions was different, i could perfectly schedule the notifications, as i do on Android. But until the moment, i couldnt find a satisfatory solution.

@rafaelsetragni
Copy link
Owner

rafaelsetragni commented Oct 21, 2020

I've oppened a Apple's support ticket to resolve this issue. Let's see if it is possible to solve it.

@rafaelsetragni rafaelsetragni added the enhancement New feature or request label Nov 6, 2020
@bbence84
Copy link

bbence84 commented Feb 6, 2021

Hi! Could we please have more clarity on which scheduled notifications work and which doesn't work exactly on iOS? E.g.:

  • Does precise date schedule work?
  • Which reoccuring kind of scheules work?

Thanks!

@rafaelsetragni
Copy link
Owner

They never improved the notification for iOS. So, ive downgrade the schedules for both platforms and keep a crontab working on 0.6.14 version. Please take a look.

@AladMocu
Copy link

Has there been any update on this topic?

@rafaelsetragni
Copy link
Owner

No, they never changed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants