Уведомления о расширении DidReceive не называется симулятором iOS с XCRUN SIMCTL PushIOS

Программируем под IOS
Anonymous
Уведомления о расширении DidReceive не называется симулятором iOS с XCRUN SIMCTL Push

Сообщение Anonymous »

Уведомление о расширении DidReceive не вызвано в симуляторе iOS с XCRUN SIMCTL push < /p>
Я работаю над приложением iOS с расширением службы уведомлений, чтобы изменять контент уведомления push. Метод расширения DidReceive (_: withContentHandler :) не вызывается, когда я отправляю уведомление с использованием xcrun simctl push в симуляторе, даже если появляется уведомление. Я подтвердил, что полезная нагрузка включает в себя «mitable-content»: 1 , а расширение встроено в приложение, но я не вижу вывода консоли или доказательства, запускаемое расширение. /> [*] идентификатор пакета расширения : com.domain.dev.notificationserviceextension
[*] среда тестирования : ios simulator (например, iPhone 15, ios 18.0)
[*] :

[*]

Код: Выделить всё

xcrun simctl push booted com.domain.dev notification.json
< /code>
[list]
  полезная нагрузка (notification.json
) [/b]:
[/list]

Код: Выделить всё

{
"aps": {
"alert": {
"title": "Test Notification",
"body": "This is a test push notification."
},
"mutable-content": 1
},
"customData": {
"key": "value"
}
}
< /code>
[list]
[*][b]notificationservice.swift[/b]:
< /ul>
import UserNotifications

class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?

override init() {
super.init()
print("NotificationService: Extension initialized at \(Date())")
}

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
print("NotificationService: didReceive called with request: \(request)")
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

if let bestAttemptContent = bestAttemptContent {
bestAttemptContent.title = "\(bestAttemptContent.title) [Modified]"
contentHandler(bestAttemptContent)
} else {
contentHandler(request.content)
}
}

override func serviceExtensionTimeWillExpire() {
print("NotificationService: Time will expire")
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
contentHandler(bestAttemptContent)
}
}
}
Что я попробовал :
  • Проверенный «mitable-content»: 1 в полезной нагрузке.
  • обеспечил расширение в приложении в «Brameworks, библиотеках и встроенном контенте» с изначальным знаком » Почему не является DidReceive (_: withContentHandler :) при использовании xcrun simctl push в симуляторе? Simulator? В идеале я бы увидел операторы Print в консоли, подтверждающие, что расширение запускается и обрабатывает запрос. [например, 18.0]
  • В настоящее время группы приложений не настроено - это требуется?


Подробнее здесь: https://stackoverflow.com/questions/795 ... with-xcrun

Вернуться в «IOS»