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

[flutter_local_notifications] Add custom repeat interval - periodicallyShowWithDuration method #2197

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mateuszluczak1996
Copy link

Add an option to set custom time for periodically showed notifications.

The problem that I have encountered on iOS devices is that repeating interval must be set to 60 seconds minimum, but I don't think that is the problem for real use case scenarios.

Sample usage:

    await flutterLocalNotificationsPlugin.periodicallyShowWithDuration(
      1,
      'repeating period title',
      'repeating period body',
      const Duration(minutes: 5),
      androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
    );

@MaikuB
Copy link
Owner

MaikuB commented Jan 17, 2024

Thanks for the PR. Will need time to give this one a good review compared to some other ones

Copy link
Owner

@MaikuB MaikuB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Got to test it out and works well. Besides the comment on the PR, do you think you'd be able to look at the following

  • addressing the linter issues picked up by Dart analyzer
  • I ran into the limitation you mentioned with Apple's APIs when the duration needs to be a minute. Rather than letting it run into a native exception that may not bubble up to be caught on the Dart side, could validation be added to ensure the duration is at least a minute on all the platform-specific implementations and throw an ArgumentError? This would allow checking the argument up-front. If you're not sure how to do it, it'd be similar to how the ID is validated to ensure it's within range where there's a validateId() call in the plugin

NotificationDetails notificationDetails, {
String? payload,
@Deprecated('Deprecated in favor of the androidScheduleMode parameter')
bool androidAllowWhileIdle = false,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove androidAllowWhileIdle argument? This is a new method so doesn't have to follow what's been done before and odd to add a new method with a deprecation notice applied to it immediately

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

Successfully merging this pull request may close these issues.

Custom intervals for periodicallyShow
2 participants