push_notification_permissions 0.1.0+3 copy "push_notification_permissions: ^0.1.0+3" to clipboard
push_notification_permissions: ^0.1.0+3 copied to clipboard

outdated

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

Push Notification Permissions #

Fork from notification_permissions change Swift to Objective-C

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

Checking Notification Permission Status #

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

This method will return an enum with the following values:

enum PermissionStatus {
	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.

Requesting Notification Permissions #

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

Future<PermissionStatus> permissionStatus = PushNotificationPermissions.getNotificationPermissionStatus({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, 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.getNotificationPermissionStatus returns status after user select answer from native permission popup.

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

2
likes
0
pub points
33%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on push_notification_permissions