Я сделал все следующее:
AppDelegate.swift
Код: Выделить всё
import 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,
);
}
Код: Выделить всё
apns: {
payload: {
aps: {
"content-available": 1,
},
},
},
Подробнее здесь: https://stackoverflow.com/questions/792 ... local-noti