NativeHostApiStubs.swift
1.46 KB
import Foundation
import Flutter
private let unsupported = "HealthKit / WearEngine / Alipay are not supported on iOS in this build."
final class HealthKitHostApiStub: HealthKitHostApi {
func checkHealthAppAuthorization() throws -> Bool { false }
func getHealthServerAuthUrl() throws -> String { "" }
func requestHealthClientAuthorization() throws -> Bool { false }
func cancelHealthAppAuthorization() throws -> Bool { false }
func performHealthUpload() throws -> HealthUploadResult {
HealthUploadResult(commonUploadSuccess: false, sleepUploadSuccess: false, errorMessage: unsupported)
}
}
final class WearEngineHostApiStub: WearEngineHostApi {
func hasAvailableDevices() throws -> Bool { false }
func checkConnectedDevice() throws -> WearDeviceInfo? { nil }
func registerMessageReceiver() throws -> Bool { false }
func sendTextMessage(message: String) throws -> Bool { false }
func sendWatchSyncPayload(jsonPayload: String) throws -> Bool { false }
}
final class AlipayHostApiStub: AlipayHostApi {
func launchAliPay(prepayData: String) throws -> AliPayResultCode { .unsupported }
}
enum NativePigeonRegistrar {
static func register(binaryMessenger: FlutterBinaryMessenger) {
HealthKitHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: HealthKitHostApiStub())
WearEngineHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: WearEngineHostApiStub())
AlipayHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: AlipayHostApiStub())
}
}