Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未触发Nativescript iOS应用程序委托方法_Nativescript_Nativescript Angular - Fatal编程技术网

未触发Nativescript iOS应用程序委托方法

未触发Nativescript iOS应用程序委托方法,nativescript,nativescript-angular,Nativescript,Nativescript Angular,我想扩展iOS应用程序代理。我正在与一个名为mobilepay()的SDK集成,在打开外部应用进行支付时需要挂接到应用程序委托。由于某些原因,在离开应用程序并打开移动支付应用程序时,不会调用这些方法(如applicationHandleOpenURL) 我一直在使用不同的示例,例如nativescript插件firebase和nativescript urlhandler。也试过了 代码如下所示: private getAppDelegate() { // Play ni

我想扩展iOS应用程序代理。我正在与一个名为mobilepay()的SDK集成,在打开外部应用进行支付时需要挂接到应用程序委托。由于某些原因,在离开应用程序并打开移动支付应用程序时,不会调用这些方法(如applicationHandleOpenURL)

我一直在使用不同的示例,例如nativescript插件firebase和nativescript urlhandler。也试过了

代码如下所示:

    private getAppDelegate() {
        // Play nice with other plugins by not completely ignoring anything already added to the appdelegate
        if (iosApp.delegate === undefined) {

          @ObjCClass(UIApplicationDelegate)
          class UIApplicationDelegateImpl extends UIResponder implements UIApplicationDelegate {
          }

          iosApp.delegate = UIApplicationDelegateImpl;
        }
        return iosApp.delegate;
    }

    private addDelegateMethods() {
        let appDelegate = this.getAppDelegate();

        console.log("er are adding this stuff to the equation lol");
          appDelegate.prototype.applicationDidFinishLaunchingWithOptions = (application, launchOptions) => {
            console.log("we are here or did finish?");
            return true;
          };

          appDelegate.prototype.applicationHandleOpenURL = (application: UIApplication, url: NSURL): boolean => {
            console.log("we are here or what?");
            MobilePayManager.sharedInstance().handleMobilePayCallbacksWithUrlSuccessErrorCancel(
                url, this.onPaymentSuccess, this.onPaymentFailure, this.onPaymentCancel);
            return true;
          };

          appDelegate.prototype.applicationOpenURLOptions = (app: UIApplication, url: NSURL, options: NSDictionary<string, any>): boolean => {
            console.log("we are here or what?");
            MobilePayManager.sharedInstance().handleMobilePayCallbacksWithUrlSuccessErrorCancel(
                url, this.onPaymentSuccess, this.onPaymentFailure, this.onPaymentCancel);
            return true;
          };

          appDelegate.prototype.openURL = (url: NSURL): boolean => {
            console.log("we are here or what?");
            MobilePayManager.sharedInstance().handleMobilePayCallbacksWithUrlSuccessErrorCancel(
                url, this.onPaymentSuccess, this.onPaymentFailure, this.onPaymentCancel);
            return true;
          };

          appDelegate.prototype.applicationOpenURLSourceApplicationAnnotation = (application: UIApplication, url: NSURL, sourceApplication: string, annotation: any): boolean => {
            console.log("we are here or what?");
            MobilePayManager.sharedInstance().handleMobilePayCallbacksWithUrlSuccessErrorCancel(
                url, this.onPaymentSuccess, this.onPaymentFailure, this.onPaymentCancel);
            return true;
          };
    }


希望in方法被称为applicationhandleopeanurl。

如果要在组件的
ngOnInit
中分配委托,那么这就是问题所在


您应该在
platformNativeScriptDynamic(…).bootstrapModule(…)
之前的
main.ts
中执行此操作。执行
ngOnInit
时,默认的应用程序委托将已经创建。

tsconfig.json中的编译器目标是什么?“target”:“es5”您能否确认您在应用程序中运行这组代码的确切时间?它是在组件的ngOnInit期间运行的。在那之前会发生吗?非常感谢。有时候解决办法很简单!
  "dependencies": {
    "@angular/animations": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "nativescript-angular": "~7.2.0",
    "nativescript-mobilepay": "1.0.5",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.3.0",
    "tns-core-modules": "~5.3.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~7.2.0",
    "@nativescript/schematics": "~0.5.0",
    "@ngtools/webpack": "~7.2.0",
    "nativescript-dev-typescript": "~0.9.0",
    "nativescript-dev-webpack": "~0.21.0"
  },