requestPermission method
Prompts the user for notification permissions.
On iOS, a dialog is shown requesting the users permission.
If provisional
is set to true
, silent notification permissions will be
automatically granted. When notifications are delivered to the device, the
user will be presented with an option to disable notifications, keep receiving
them silently or enable prominent notifications.
On Android, is it not required to call this method. If called however,
a NotificationSettings
class will be returned with
NotificationSettings.authorizationStatus
returning
AuthorizationStatus.authorized
.
On Web, a popup requesting the users permission is shown using the native browser API.
Implementation
@override
Future<NotificationSettings> requestPermission({
bool alert = true,
bool announcement = false,
bool badge = true,
bool carPlay = false,
bool criticalAlert = false,
bool provisional = false,
bool sound = true,
}) {
return convertWebExceptions(() async {
String status =
(await web.Notification.requestPermission().toDart) as String;
return utils.getNotificationSettings(status);
});
}