我正在与BLE设备通信的NativeScript应用程序上工作,我需要使用信标来重新启动该应用程序。
我创建了一个nativescript插件,以使用以本机代码(swift)实现的自定义BLE SDK,在SDK中使用了startMonitoring(region)方法,只要应用程序是前台/后台,它就可以正常工作,但是如果该应用程序是关闭,我收到此错误:
“应用程序委托如果要使用主故事板文件,则必须实现window属性。”
我试图在NativeScript中添加带有window属性的自定义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;
}
尝试吸气剂,
export class CustomAppDelegate extends UIResponder implements UIApplicationDelegate {
....
get window() {
return undefined;
}
}