requestPermissionToSendNotifications method
Future<bool>
requestPermissionToSendNotifications({
- String? channelKey,
- List<
NotificationPermission> permissions = const [NotificationPermission.Alert, NotificationPermission.Sound, NotificationPermission.Badge, NotificationPermission.Vibration, NotificationPermission.Light],
override
Prompts the user to enabled notifications
Implementation
@override
Future<bool> requestPermissionToSendNotifications(
{String? channelKey,
List<NotificationPermission> permissions = const [
NotificationPermission.Alert,
NotificationPermission.Sound,
NotificationPermission.Badge,
NotificationPermission.Vibration,
NotificationPermission.Light
]}) async {
final List<String> permissionList = [];
for (final permission in permissions) {
String? permissionValue =
LocalAssertUtils.toSimpleEnumString(permission);
if (permissionValue != null) permissionList.add(permissionValue);
}
final List<Object?>? missingPermissions = await methodChannel.invokeMethod(
CHANNEL_METHOD_REQUEST_NOTIFICATIONS, {
NOTIFICATION_CHANNEL_KEY: channelKey,
NOTIFICATION_PERMISSIONS: permissionList
});
return missingPermissions?.isEmpty ?? false;
}