fix: resolve import paths and module loading errors

This commit is contained in:
2026-08-07 12:41:04 +02:00
parent 43b6467efb
commit 11f0d16515
15 changed files with 388 additions and 14 deletions
@@ -1,63 +0,0 @@
import ExpoModulesCore
public class WatchConnectivityModule: Module {
public func definition() -> Definition {
Name("WatchConnectivity")
AsyncFunction("isSupported") { () -> Bool in
return WCSession.isSupported()
}
AsyncFunction("isPaired") { () -> Bool in
return WCSession.default.isPaired
}
AsyncFunction("isWatchAppInstalled") { () -> Bool in
return WCSession.default.isWatchAppInstalled
}
AsyncFunction("isReachable") { () -> Bool in
return WCSession.default.isReachable
}
AsyncFunction("sendWorkoutPlan") { (plan: [String: Any], promise: Promise) in
var message = plan
message["type"] = "workoutPlan"
if WCSession.default.isReachable {
WCSession.default.sendMessage(message, replyHandler: { reply in
promise.resolve(reply)
}, errorHandler: { error in
promise.reject(error)
})
} else {
WCSession.default.transferUserInfo(message)
promise.resolve(["status": "queued"])
}
}
AsyncFunction("sendWorkoutCompletion") { (data: [String: Any], promise: Promise) in
var message = data
message["type"] = "workoutCompleted"
if WCSession.default.isReachable {
WCSession.default.sendMessage(message, replyHandler: { reply in
promise.resolve(reply)
}, errorHandler: { error in
promise.reject(error)
})
} else {
WCSession.default.transferUserInfo(message)
promise.resolve(["status": "queued"])
}
}
AsyncFunction("getApplicationContext") { () -> [String: Any]? in
return WCSession.default.receivedApplicationContext as? [String: Any]
}
AsyncFunction("updateApplicationContext") { (context: [String: Any]) in
try? WCSession.default.updateApplicationContext(context)
}
}
}
+15 -2
View File
@@ -1,3 +1,16 @@
import { requireNativeModule } from "expo-modules-core";
import { requireOptionalNativeModule } from "expo-modules-core";
export default requireNativeModule("WatchConnectivity");
let WatchConnectivity: any;
WatchConnectivity = requireOptionalNativeModule("WatchConnectivity") ?? {
isSupported: async () => false,
isPaired: async () => false,
isWatchAppInstalled: async () => false,
isReachable: async () => false,
sendWorkoutPlan: async () => ({ error: "WatchConnectivity native module not available" }),
sendWorkoutCompletion: async () => ({ error: "WatchConnectivity native module not available" }),
getApplicationContext: async () => null,
updateApplicationContext: async () => {},
};
export default WatchConnectivity;