NotificationPermissionHelper class
Helper class for managing notification permission state and logic.
Provides utilities for:
- Checking permission status
- Determining optimal permission request timing
- Tracking permission request history
- Deciding when to show reminders or recovery dialogs
This class owns all permission-related SharedPreferences keys with the
dreamic_ prefix to avoid collisions with consuming apps.
Constructors
- NotificationPermissionHelper({NotificationService? notificationService})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
autoClearIfGranted(
) → Future< bool> - Checks permission status and clears tracking data if granted.
-
canPromptForPermission(
) → Future< bool> - Returns true if the app can prompt for permissions.
-
clearGoToSettingsPromptInfo(
) → Future< void> - Clears stored "go to settings" prompt info.
-
clearNotificationDenialInfo(
) → Future< void> - Clears stored denial info (e.g., after user grants permission via settings).
-
ensureMigrated(
) → Future< void> - Ensures migration has been performed. Call this before any SharedPreferences access.
-
getGoToSettingsPromptInfo(
) → Future< GoToSettingsPromptInfo?> - Gets structured information about "go to settings" prompts.
-
getNotificationDenialInfo(
) → Future< NotificationDenialInfo?> - Gets structured information about notification permission denials.
-
getOptimalContext(
) → Future< String> - Suggests the optimal context for requesting permissions.
-
getPermissionDenialCount(
) → Future< int> - Gets the number of times permissions have been denied.
-
getPermissionRequestCount(
) → Future< int> - Gets the number of times permissions have been requested.
-
hasRequestedPermissionBefore(
) → Future< bool> - Returns true if permissions have been requested at least once.
-
isPermissionDenied(
) → Future< bool> - Returns true if notification permissions are denied.
-
isPermissionGranted(
) → Future< bool> - Returns true if notification permissions are granted.
-
isPermissionNotDetermined(
) → Future< bool> - Returns true if notification permissions have not been determined yet.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordBlockedRequest(
) → Future< void> - Records when a permission request was blocked by the system.
-
recordDenial(
{required bool isPermanent}) → Future< void> - Records a permission denial.
-
recordGoToSettingsPrompt(
{required bool openedSettings}) → Future< void> - Records that a "go to settings" prompt was shown.
-
shouldRequestPermissions(
{NotificationFlowConfig? config}) → Future< bool> - Returns true if the app should request permissions now.
-
shouldShowPeriodicReminder(
{int? intervalDays}) → Future< bool> - Returns true if enough time has passed to show a periodic reminder.
-
shouldShowPermissionRationale(
) → Future< bool> - Returns true if the app should show a rationale before requesting permissions.
-
shouldShowSettingsPrompt(
{NotificationFlowConfig? config}) → Future< bool> - Returns true if the app should show a settings prompt.
-
toString(
) → String -
A string representation of this object.
inherited
-
trackPermissionRequest(
) → Future< void> - Tracks a permission request attempt.
-
updateLastReminderDate(
) → Future< void> - Updates the last reminder date to now.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited