Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions WatchApp Extension/ExtensionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ class ExtensionDelegate: NSObject, WKApplicationDelegate {
private var observers: [NSKeyValueObservation] = []
private var notifications: [NSObjectProtocol] = []

// WKApplication.shared().delegate is nil under the SwiftUI app lifecycle.
private static var instance: ExtensionDelegate!

static func shared() -> ExtensionDelegate {
return WKApplication.shared().extensionDelegate
return instance
}

let loopManager = LoopDataManager.shared
Expand All @@ -42,6 +45,8 @@ class ExtensionDelegate: NSObject, WKApplicationDelegate {
override init() {
super.init()

Self.instance = self

let session = WCSession.default
session.delegate = self

Expand Down Expand Up @@ -422,10 +427,3 @@ extension ExtensionDelegate {
WKApplication.shared().rootInterfaceController?.presentAlert(withTitle: error.localizedDescription, message: (error as NSError).localizedRecoverySuggestion ?? (error as NSError).localizedFailureReason, preferredStyle: .alert, actions: [WKAlertAction.dismissAction()])
}
}


fileprivate extension WKApplication {
var extensionDelegate: ExtensionDelegate! {
return delegate as? ExtensionDelegate
}
}