Search packages, repositories and app categories

Package detailsv0.6.1

notification_permissions

A plugin to check and ask for notification permissions on Android and iOS

AndroidiOS
30-day downloads
1.3K
Likes
117
Pub points
120

Install package

flutter pub add notification_permissions

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The notification_permissions package provides a simple way to check and request notification permissions on both Android and iOS platforms. It enables apps to determine the current permission status and prompt users to grant or deny notifications, ensuring compliance with platform-specific requirements. The plugin is lightweight and integrates seamlessly into Flutter applications, supporting both runtime checks and user interaction flows. It helps developers manage notification access responsibly and improve user experience by guiding users through permission requests at appropriate times.

Use cases

  • Checking current notification permission status
  • Requesting notification permissions from users
  • Handling permission responses in app logic
  • Ensuring compliance with platform guidelines
  • Improving user engagement through timely notifications

Key features

  • Cross-platform support for Android and iOS
  • Simple API for checking and requesting permissions
  • Supports asynchronous permission handling
  • Provides clear permission status states
  • Minimal boilerplate code required

Suitable for

  • Apps requiring push notifications
  • User-facing apps needing permission guidance
  • Developers building privacy-conscious features
  • Flutter apps targeting both mobile platforms
  • Projects emphasizing user consent and transparency

Considerations

  • Requires proper handling of permission denial scenarios
  • May trigger system dialogs that affect user flow
  • Does not work without proper app configuration on each platform
  • Limited to notification permissions only (not other types)
  • Needs testing on actual devices due to OS-level behavior

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Flutter Notification Permissions

Package to check for and ask for Notification Permissions on iOS and Android.

Checking Notification Permission Status

Future<PermissionStatus> permissionStatus =
    NotificationPermissions.getNotificationPermissionStatus();

This method will return an enum with the following values:

enum PermissionStatus {
  provisional, // iOS Only
	granted,
	unknown,
	denied
}

In iOS, a permission is unknown when the user hasn’t accepted or refuse the notification permissions. In Android this state will never occur, since the permission will be granted by default and it will be denied if the user goes to the app settings and turns off notifications for the app. The provisional status will also offer the same behavior.

Requesting Notification Permissions

If the PermissionStatus is denied or unknown, we can ask the user for the Permissions:

Future<PermissionStatus> permissionStatus = NotificationPermissions.requestNotificationPermissions({NotificationSettingsIos iosSettings, bool openSettings});

On Android, if the permission is denied, this method will open the app settings.

In iOS, if the permission is unknown or provisional, it will show an alert window asking the user for the permission. On the other hand, if the permission is denied it has the same behaviour as Android, opening the app settings. Also in iOS if you set openSettings to false settings window won't be opened. You will get denied status. NotificationPermissions.requestNotificationPermissions returns status after user select answer from native permission popup.

Note: if the permission is granted, this method will not do anything.

iOS Error: Swift.h not found

If your project is in Objective-C, you will have to do the changes referenced in this SO post in order to solve the issue:

'notification_permissions/notification_permissions-Swift.h' file not found
    #import <notification_permissions/notification_permissions-Swift.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

Add use_frameworks! in target Runner in your (YOUR_PROJECT)/ios/Podfile

target 'Runner' do
  use_frameworks! # Add here

Special Thanks

Special thanks to fedecastelli for helping me in the Swift Code!

Categories

Source repository

Projects using this package