view нет
class RemotePushNotificationManager: NSObject, UNUserNotificationCenterDelegate, ObservableObject {
@Published var testMessage: String?
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
print(userInfo)
if let aps = userInfo["aps"] as? NSDictionary {
if let alert = aps["alert"] as? String {
print(alert)
testMessage = alert
}
}
completionHandler()
}
struct NotificaionsView: View {
@StateObject var rpnm = RemotePushNotificationManager()
var body: some View {
Text(rpnm.testMessage ?? "NOTHING")
Попробуй в свойстве сделать так willSet{ objectWillChange.send() }
увы =( но нет эффетка
Обсуждают сегодня