fix(plugin): lazy HKHealthStore + load() override pour debug
Hypothèse : HKHealthStore() à l'init de classe peut causer un échec silencieux qui empêche Capacitor d'enregistrer le plugin. Lazy init. Aussi : public override func load() avec NSLog pour qu'on voie dans les logs natifs si Capacitor charge bien la classe au boot.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
// // r.available = bool (false si pas de route associée, pas d'autorisation, etc.)
|
// // r.available = bool (false si pas de route associée, pas d'autorisation, etc.)
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import UIKit
|
||||||
import Capacitor
|
import Capacitor
|
||||||
import HealthKit
|
import HealthKit
|
||||||
import CoreLocation
|
import CoreLocation
|
||||||
@@ -25,7 +26,12 @@ public class CoachHealthRoutePlugin: CAPPlugin, CAPBridgedPlugin {
|
|||||||
CAPPluginMethod(name: "getRoute", returnType: CAPPluginReturnPromise),
|
CAPPluginMethod(name: "getRoute", returnType: CAPPluginReturnPromise),
|
||||||
]
|
]
|
||||||
|
|
||||||
private let store = HKHealthStore()
|
private lazy var store = HKHealthStore()
|
||||||
|
|
||||||
|
public override func load() {
|
||||||
|
NSLog("[CoachHealthRoute] plugin loaded (iOS \(UIDevice.current.systemVersion))")
|
||||||
|
super.load()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func isAvailable(_ call: CAPPluginCall) {
|
@objc func isAvailable(_ call: CAPPluginCall) {
|
||||||
call.resolve(["available": HKHealthStore.isHealthDataAvailable()])
|
call.resolve(["available": HKHealthStore.isHealthDataAvailable()])
|
||||||
|
|||||||
Reference in New Issue
Block a user