Код: Выделить всё
{
"GCM": {
"notification": {
"title": "Sample message for Android endpoints",
"body": "(Encrypted)",
"mutable_content": true,
"category": "SECRET"
},
"data": {
"ENCRYPTED_DATA": "Salted__·öîQÊ$UDì_¶Ù∞èΩ^¬%gq∞NÿÒQùw",
"imageUrl": "https://picsum.photos/200/300"
},
"aps": {
"alert": {
"title": "Title",
"body": "Body"
},
"mutable-content": 1
}
}
}
< /code>
При тестировании с этой полезной нагрузкой я получаю удаленные уведомления в приложении Flutter, но расширение службы уведомлений вообще не запускается. Я проверил его, имея точку останова и заявление печати внутри переопределения DidReceive. Это то, что я вижу в Firebase onmessage Sulderer, когда получено удаленное уведомление (даже без добавления словаря APS в полезной нагрузке). < /P>
flutter: FCM Category: SECRET
flutter: FCM Mutable Content: true
flutter: FCM Content Available: false
flutter: FCM Message Type: null
flutter: FCM Notification: Instance of 'RemoteNotification'
flutter: FCM Data: {ENCRYPTED_DATA: Salted__·öîQÊ$UDì_¶Ù∞èΩ^¬%gq∞NÿÒQùw, imageUrl: https://picsum.photos/200/300}
< /code>
Вот уведомления service.swift < /p>
//
// NotificationService.swift
// AppNotificationServiceExtension
//
// Created by Rohit Kokate on 07/05/24.
//
import UserNotifications
import FirebaseMessaging
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
print("UNNotificationRequest : \(bestAttemptContent?.title ?? "default")")
if let bestAttemptContent = bestAttemptContent {
// Modify the notification content here...
bestAttemptContent.title = "\(bestAttemptContent.title) [modified]"
// contentHandler(bestAttemptContent)
Messaging.serviceExtension().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
}
}
override func serviceExtensionTimeWillExpire() {
// Called just before the extension will be terminated by the system.
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
Код: Выделить всё
target 'AppNotificationServiceExtension' do
use_frameworks!
pod 'Firebase/Messaging'
end
[*] Цели развертывания проекта и Match Match
'Копия только при установке' не выполняется в apped foundation extension . /> Я попытался перезагрузить устройство < /li>
Я прошел аналогичные вопросы, поэтому вопросы без какого -либо успеха < /li>
< /ul>
ps: из Firebase я видел документацию, связанную с расширением службы уведомлений, включающей только отправку изображения в уведомление. И ничего для других вариантов использования.
Подробнее здесь: https://stackoverflow.com/questions/784 ... th-flutter