[Feature request] Expose UNTimeIntervalNotificationTrigger with no repeat
Hey! Currently, the plugin doesn't allow taking advantage of UNTimeIntervalNotificationTrigger with the repeat set to false and it would be really nice to have this possibility exposed within the Flutter plugin.
The plugin currently exposes periodicallyShow that uses UNTimeIntervalNotificationTrigger with the repeat true.
My use-case is using the plugin for showing a notification on closing the app. It works natively by running a scheduled notification with time interval trigger and no repeat, but does not by other means (it can also be safely called from Flutter side during app exiting so no problem on that part), but the plugin doesn't expose that.
Could you look into a submitting a PR for this?
Hi @Albert221, does zonedSchedule() accomplish what you're looking for? Also, see #2492 and the "Scheduling a notification section in the new docs
Specifically, the UNTimeIntervalNotificationTrigger just takes in a number of seconds as input. You could do the same thing in Dart to find when you want to show the notification, then call .zonedSchedule() like this:
// show a notification in 30 minutes:
initTimezones(); // see the README
plugin.zonedSchedule(
// id, title, body
scheduledDate: TZDateTime.now(tz.location).add(Duration(seconds: 30)),
);
@Levi-Lesches hey, I understand that I can calculate date to use in scheduledDate by adding interval to current time, so I can use zonedSchedule. But I can't use zonedSchedule, because it uses iOS's UNCalendarNotificationTrigger and I must use UNTimeIntervalNotificationTrigger.
My use-case is using the plugin for showing a notification on closing the app. It works natively by running a scheduled notification with time interval trigger and no repeat, but does not by other means.
Showing a notification with UNCalendarNotificationTrigger, only with UNTimeIntervalNotificationTrigger it does work.
Can you explain what's not working for you, why you must use UNTimeIntervalNotificationTrigger instead of UNCalendarNotificationTrigger? Is the notification not appearing? Are you getting an error?
I don't think it's an end goal to expose which type of trigger is being used in the API since they're interchangeable, and the concept isn't relevant for other platforms. I couldn't find anything in the API docs or sources online saying that they should work differently, aside from taking in different inputs.
The notification just does not appear. That's how iOS is I believe. I may create a simple demo for you tomorrow or later if you want
I mean, others use this plugin successfully, so I'd bet that's not the case ;). And plus, apple offers the calendar trigger for a reason, it's not like they're simply offering a solution that won't work. Like I mentioned, the docs don't show any sort of difference between the two triggers either.
Have you tried following all the setup instructions in the readme? If so, yes, please create a sample repo that we can clone that will reproduce your issue. I personally don't use Mac or iOS, so you'll probably have to wait to see if someone else can help (@MaikuB do you test iOS?)
@Levi-Lesches yes I do
As for the use case mentioned, I agree that UNCalendarNotificationTrigger should work for this