mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
Hub: - add encrypted Live Activity token registry, registration API, and update/end pushes over direct APNs - enable only for HAPI_IOS_PUSH=apns; relay reports remote:false - keep content-state encrypted with the per-install push key and a domain-separated AAD iOS: - add ActivityKit coordinator, HapiWidgets extension, lock-screen and Dynamic Island UI, encrypted content-state, deep links, and settings toggle - cap concurrent activities and reconcile across hub switches Docs/tests: - native contract, privacy, READMEs, localization catalogs - cross-language cipher fixture and hub/iOS unit tests via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
53 lines
1.8 KiB
Swift
53 lines
1.8 KiB
Swift
import HapiProtocol
|
|
import OSLog
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct HapiApp: App {
|
|
/// APNs registration callbacks + notification-center delegate install
|
|
/// (P3) — SwiftUI lifecycle apps get them only through the adaptor.
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
|
@State private var model = AppModel()
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
private let log = Logger(subsystem: "run.hapi.companion", category: "app")
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
.environment(model)
|
|
.onOpenURL { url in
|
|
handleIncomingURL(url)
|
|
}
|
|
}
|
|
.onChange(of: scenePhase, initial: true) { _, phase in
|
|
model.handleScenePhase(phase)
|
|
}
|
|
.commands {
|
|
HapiCommands()
|
|
}
|
|
}
|
|
|
|
/// `hapicompanion://bind?hub=<url>&code=<accessToken>` — parse and route
|
|
/// through `AppModel`: unpaired → pairing confirm; already paired to that
|
|
/// hub → switch with a notice; a different hub → add-hub confirm.
|
|
///
|
|
/// Live Activities open `hapicompanion://sessions/<id>[?hub=<url>]`;
|
|
/// that form is routed through the same notification-target path.
|
|
///
|
|
/// Never log the URL itself: the bind query carries the access token.
|
|
private func handleIncomingURL(_ url: URL) {
|
|
if let link = BindLink.parse(url.absoluteString) {
|
|
if !model.handleBindLink(link) {
|
|
log.warning("Bind link carried an unusable hub URL")
|
|
}
|
|
return
|
|
}
|
|
if let link = SessionLink.parse(url.absoluteString) {
|
|
model.handleSessionLink(link)
|
|
return
|
|
}
|
|
log.warning("Ignoring malformed URL (scheme: \(url.scheme ?? "none", privacy: .public))")
|
|
}
|
|
}
|