如何在IBM Worklight上使用URL Scheme打开iOS Native Page?

时间:2016-01-26 11:41:23

标签: ios cordova ibm-mobilefirst native url-scheme

我需要检测URL Scheme调用,如果发生此调用,我需要启动本机页面。

到目前为止,我已经设法构建了URL方案检测,但是如何加载我的视图而不是IBM Worklight webview?

在AppDelegate实现中,我有以下方法:

    // This method is called after the WL web framework initialization is complete and web resources are ready to be used.

-(void)wlInitWebFrameworkDidCompleteWithResult (WLWebFrameworkInitResult *)result {
    if ([result statusCode] == WLWebFrameworkInitResultSuccess) {
        [self wlInitDidCompleteSuccessfully]; //declared below
    } else {
        [self wlInitDidFailWithResult:result];
    }
}

-(void)wlInitDidCompleteSuccessfully {
    UIViewController* rootViewController = self.window.rootViewController;

    // Create a Cordova View Controller
    CDVViewController* cordovaViewController = [[CDVViewController alloc] init] ;

    cordovaViewController.startPage = [[WL sharedInstance] mainHtmlFilePath];
    cordovaViewController.webView.scrollView.bounces = YES;

    // Adjust the Cordova view controller view frame to match its parent view bounds
    cordovaViewController.view.frame = rootViewController.view.bounds;

    // Display the Cordova view
    [rootViewController addChildViewController:cordovaViewController];
    [rootViewController.view addSubview:cordovaViewController.view];
}

我的想法是使用我的其他方法调用此方法,但问题是在 wlInitWebFrameworkDidCompleteWithResult 的调用之后调用 handleOpenURL 方法。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

您应该查看以下教程,该教程解释了如何“控制”混合应用程序的启动流程。本教程针对MobileFirst应用程序进行了调整,您正在使用Worklight(MobileFirst的旧版本),因此您可能需要在viewcontroller中针对特定应用程序实现进一步调整它:https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/adding-native-functionality/ios-adding-native-ui-elements-hybrid-applications/