Skip to content

Commit

Permalink
Getting the notification functionality back in SwiftUI watch app
Browse files Browse the repository at this point in the history
  • Loading branch information
timbms committed Nov 8, 2023
1 parent 56bd336 commit 5fa2f18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions openHABWatch/Extension/PushNotificationPayload.apns
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"thread-id": "5280"
},

"openHABMessageIndexKey": 1

"openHABMessageIndexKey": 1,

"Simulator Target Bundle": "es.spaphone.openhab.watchkitapp"

}
9 changes: 7 additions & 2 deletions openHABWatch/OpenHABWatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// SPDX-License-Identifier: EPL-2.0

import SwiftUI
import UserNotifications

@main
struct OpenHABWatch: App {
Expand All @@ -30,11 +31,15 @@ struct OpenHABWatch: App {
Label("Preferences", systemImage: "person.crop.circle.fill")
}
}
.task {
let center = UNUserNotificationCenter.current()
_ = try? await center.requestAuthorization(
options: [.alert, .sound, .badge]
)
}
// .environmentObject(userData)
}

#if os(watchOS)
WKNotificationScene(controller: NotificationController.self, category: "openHABNotification")
#endif
}
}

0 comments on commit 5fa2f18

Please sign in to comment.