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

[Feature request] Expose UNTimeIntervalNotificationTrigger with no repeat #2399

Open
Albert221 opened this issue Sep 4, 2024 · 7 comments
Open
Labels
help wanted Extra attention is needed

Comments

@Albert221
Copy link

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.

@MaikuB MaikuB added the help wanted Extra attention is needed label Oct 13, 2024
@MaikuB
Copy link
Owner

MaikuB commented Oct 13, 2024

Could you look into a submitting a PR for this?

@Levi-Lesches
Copy link
Contributor

Levi-Lesches commented Dec 13, 2024

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)),
);

@Albert221
Copy link
Author

@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.

@Levi-Lesches
Copy link
Contributor

Levi-Lesches commented Dec 13, 2024

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.

@Albert221
Copy link
Author

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

@Levi-Lesches
Copy link
Contributor

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?)

@MaikuB
Copy link
Owner

MaikuB commented Dec 13, 2024

@Levi-Lesches yes I do

As for the use case mentioned, I agree that UNCalendarNotificationTrigger should work for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants