requestNotificationPermission method
Requests notification permissions from the user.
Shows the system permission dialog to the user. On web, this always returns false as web notification permissions are not supported.
Returns:
trueif the user granted permission,falseotherwise
Implementation
Future<bool> requestNotificationPermission() async {
if (kIsWeb) return false;
final settings = await _firebaseMessaging.requestPermission(
alert: true,
badge: true,
sound: true,
carPlay: true,
provisional: true,
announcement: true,
criticalAlert: true,
providesAppNotificationSettings: false,
);
return settings.authorizationStatus == AuthorizationStatus.authorized;
}