1

我正在开发与 BLE 设备通信的 NativeScript 应用程序,我需要使用信标重新启动应用程序。

我创建了一个 nativescript 插件来使用在本机代码 (swift) 中实现的自定义 BLE SDK,在 SDK 中使用 startMonitoring(region) 方法,只要应用程序是前台/后台,它就可以正常工作,但是如果应用程序关闭我收到此错误:

“如果要使用主情节提要文件,应用程序委托必须实现窗口属性。”

我尝试在 NativeScript 中添加一个带有窗口属性的自定义 AppDelegate,但没有任何改变,这是我的 CustomAppDelegate:

export class CustomAppDelegate extends UIResponder implements UIApplicationDelegate {
    public static ObjCProtocols = [UIApplicationDelegate];
    window:UIWindow;

    applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<string, any>): boolean {
        console.log("applicationWillFinishLaunchingWithOptions: " + launchOptions)

        return true;
    }

    applicationDidBecomeActive(application: UIApplication): void {
        console.log("applicationDidBecomeActive: " + application)
    }
}

if (platform.isIOS) {
    ios.delegate = CustomAppDelegate;
}
4

1 回答 1

0

试试吸气剂,

export class CustomAppDelegate extends UIResponder implements UIApplicationDelegate {
    ....

    get window() {
       return undefined;
    }
}
于 2019-11-09T22:02:20.877 回答