fix: resolve import paths and module loading errors
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
require 'json'
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'WatchConnectivityModule'
|
||||
s.version = package['version']
|
||||
s.summary = 'WatchConnectivity Expo module'
|
||||
s.homepage = 'https://github.com/swimbuddy'
|
||||
s.license = 'MIT'
|
||||
s.author = 'SwimBuddy'
|
||||
s.source = { git: '' }
|
||||
s.platform = :ios, '16.4'
|
||||
s.swift_version = '5.0'
|
||||
|
||||
s.dependency 'ExpoModulesCore'
|
||||
|
||||
s.source_files = '*.swift'
|
||||
|
||||
s.frameworks = 'WatchConnectivity'
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"platforms": ["ios"],
|
||||
"ios": {
|
||||
"modules": ["WatchConnectivityModule"],
|
||||
"podspecPath": "./WatchConnectivityModule.podspec"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import ExpoModulesCore
|
||||
import WatchConnectivity
|
||||
|
||||
public class WatchConnectivityModule: Module {
|
||||
public func definition() -> ModuleDefinition {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "watch-connectivity",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user