createChannel method
Creates a single notification channel.
Example:
await manager.createChannel(AndroidNotificationChannel(
'custom_channel',
'Custom Notifications',
description: 'Custom notification category',
importance: Importance.max,
));
Implementation
Future<void> createChannel(AndroidNotificationChannel channel) async {
if (kIsWeb || !Platform.isAndroid) {
return;
}
try {
final androidPlugin =
_plugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();
if (androidPlugin == null) {
loge(StackTrace.current, 'AndroidFlutterLocalNotificationsPlugin not available');
return;
}
await androidPlugin.createNotificationChannel(channel);
logd('Created notification channel: ${channel.id}');
} catch (e, stack) {
loge(stack, 'Failed to create channel ${channel.id}: $e');
}
}