NativeScript-使用iBeacon重新启动应用程序,AppDelegate必须实现window属性

问题描述 投票:1回答:1

我正在与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;
}
ios swift delegates nativescript ibeacon
1个回答
0
投票

尝试吸气剂,

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

    get window() {
       return undefined;
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.