我想在应用程序处于前台时隐藏通知,但 IOS 即使在前台也显示通知。通常,当应用程序处于前台时,不会显示 FCM 通知。这是我的代码
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(channel);
AndroidInitializationSettings androidInitializationSettings =
AndroidInitializationSettings('@mipmap/ic_launcher');
IOSInitializationSettings iosInitializationSettings =
IOSInitializationSettings();
InitializationSettings initializationSettings = InitializationSettings(
android: androidInitializationSettings, iOS: iosInitializationSettings);
flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: onSelectNotification);
final bool? result = await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);