Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ final class AddCarbsInterfaceController: WKInterfaceController, IdentifiableClas
do {
try WCSession.default.sendCarbEntryMessage(entry,
replyHandler: { (suggestion) in
WKInterfaceDevice.current().play(.success)
DispatchQueue.main.async {
WKExtension.shared().rootInterfaceController?.presentController(withName: BolusInterfaceController.className, context: suggestion)
}
Expand Down
13 changes: 9 additions & 4 deletions WatchApp Extension/Controllers/BolusInterfaceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ final class BolusInterfaceController: WKInterfaceController, IdentifiableClass {
let bolus = SetBolusUserInfo(value: bolusValue, startDate: Date())

do {
try WCSession.default.sendBolusMessage(bolus) { (error) in
DispatchQueue.main.async {
ExtensionDelegate.shared().present(error)
try WCSession.default.sendBolusMessage(bolus,
replyHandler: { _ in
WKInterfaceDevice.current().play(.success)
},
errorHandler: { (error) in
DispatchQueue.main.async {
ExtensionDelegate.shared().present(error)
}
}
}
)
} catch {
presentAlert(
withTitle: NSLocalizedString("Bolus Failed", comment: "The title of the alert controller displayed after a bolus attempt fails"),
Expand Down
5 changes: 3 additions & 2 deletions WatchApp Extension/Extensions/WCSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ extension WCSession {
)
}

func sendBolusMessage(_ userInfo: SetBolusUserInfo, errorHandler: @escaping (Error) -> Void) throws {
func sendBolusMessage(_ userInfo: SetBolusUserInfo, replyHandler: @escaping ([String: Any]) -> Void,
errorHandler: @escaping (Error) -> Void) throws {
guard activationState == .activated else {
throw MessageError.activationError
}
Expand All @@ -50,7 +51,7 @@ extension WCSession {
}

sendMessage(userInfo.rawValue,
replyHandler: { reply in },
replyHandler: replyHandler,
errorHandler: errorHandler
)
}
Expand Down