Я использую flutter_local_notifications для отображения уведомлений. На iPhone уведомления не отображаются, когда приложение находится в фоновом режиме. Но когда я снова открываю приложение, уведомления отображаются.
Я сделал все следующее:
AppDelegate.swiftimport Flutter
import UIKit
import flutter_local_notifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as
UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Затем в моем классе службы уведомлений:
Future _setupIOSHeadsUp() async {
await _firebaseMessaging.setForegroundNotificationPresentationOptions(
sound: true,
badge: true,
);
}
Future showBigTextNotification({
required String title,
required String body,
String? payload,
}) async {
// Set up BigTextStyleInformation
final bigTextStyleInformation = BigTextStyleInformation(
body, // Big text content
contentTitle: title, // Title for expanded view
);
final notificationDetails = NotificationDetails(
android: AndroidNotificationDetails(
notificationChannel.id,
notificationChannel.name,
channelDescription: notificationChannel.description,
importance: notificationChannel.importance,
priority: Priority.high,
styleInformation: bigTextStyleInformation,
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentSound: true,
presentBadge: true,
),
);
return _flutterLocalNotifications.show(
Random().nextInt(100),
title,
body,
notificationDetails,
payload: payload,
);
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... local-noti
Уведомления не отображаются, когда приложение находится в фоновом режиме (ios, flutter_local_notifications) ⇐ IOS
Программируем под IOS
1732579299
Anonymous
Я использую flutter_local_notifications для отображения уведомлений. На iPhone уведомления не отображаются, когда приложение находится в фоновом режиме. Но когда я снова открываю приложение, уведомления отображаются.
Я сделал все следующее:
AppDelegate.swiftimport Flutter
import UIKit
import flutter_local_notifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as
UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Затем в моем классе службы уведомлений:
Future _setupIOSHeadsUp() async {
await _firebaseMessaging.setForegroundNotificationPresentationOptions(
sound: true,
badge: true,
);
}
Future showBigTextNotification({
required String title,
required String body,
String? payload,
}) async {
// Set up BigTextStyleInformation
final bigTextStyleInformation = BigTextStyleInformation(
body, // Big text content
contentTitle: title, // Title for expanded view
);
final notificationDetails = NotificationDetails(
android: AndroidNotificationDetails(
notificationChannel.id,
notificationChannel.name,
channelDescription: notificationChannel.description,
importance: notificationChannel.importance,
priority: Priority.high,
styleInformation: bigTextStyleInformation,
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentSound: true,
presentBadge: true,
),
);
return _flutterLocalNotifications.show(
Random().nextInt(100),
title,
body,
notificationDetails,
payload: payload,
);
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79224920/notifications-not-showing-when-app-is-in-the-background-ios-flutter-local-noti[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия