requestPermissions static method
Future<void>
requestPermissions({
- bool alert = true,
- bool badge = true,
- bool sound = true,
- bool provisional = false,
- bool critical = false,
- bool vibrate = true,
- bool enableLights = true,
- String channelId = "default_notification_channel_id",
- String channelName = "Default Notification Channel",
- String? description,
- String? groupId,
- Importance? importance,
- List<
int> ? vibratePattern, - Color? ledColor,
- AudioAttributesUsage? audioAttributesUsage,
Request permissions
Implementation
static Future<void> requestPermissions({
bool alert = true,
bool badge = true,
bool sound = true,
bool provisional = false,
bool critical = false,
bool vibrate = true,
bool enableLights = true,
String channelId = "default_notification_channel_id",
String channelName = "Default Notification Channel",
String? description,
String? groupId,
Importance? importance,
List<int>? vibratePattern,
Color? ledColor,
AudioAttributesUsage? audioAttributesUsage,
}) async {
if (kIsWeb) {
throw Exception("Push notifications are not supported on the web");
}
await Nylo.localNotifications(
(FlutterLocalNotificationsPlugin localNotifications) async {
if (Platform.isIOS) {
await localNotifications
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions();
return;
}
if (Platform.isAndroid) {
await localNotifications
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();
return;
}
throw Exception("Platform not supported");
});
}