Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

does not open links _blank #103

Open
vladmobile opened this issue Feb 10, 2021 · 2 comments
Open

does not open links _blank #103

vladmobile opened this issue Feb 10, 2021 · 2 comments

Comments

@vladmobile
Copy link

vladmobile commented Feb 10, 2021

Hi!

Can you give an example of how to implement Obj-C functionality in NativeScript (Angular)

I want this

{

  • (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
    {
    if (navigationAction.navigationType == UIWebViewNavigationTypeLinkClicked) {
    NSURL *url = navigationAction.request.URL;

      if([url.host hasPrefix:@"someurl"] || [url.host hasPrefix:@"someurl2"]){
          [self loadWebView:url];
      }else{
          [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
      }
      decisionHandler(WKNavigationActionPolicyCancel);
    

    }else{
    decisionHandler(WKNavigationActionPolicyAllow);
    }
    }
    }
    Please, if it's not difficult to provide an example code

@m-abs
Copy link
Contributor

m-abs commented Feb 17, 2021

What you want is very difficult to do in NativeScript and it isn't something we can support.

But you can try to use the event shouldOverrideUrlLoading, when you can use arg.cancel = true to stop the page load before it starts.

@ekirchdev
Copy link

I probably have a similar problem. The page displayed in the webview wants to open an URL in a new tab. iOS prohibits this by default. I want to catch the URL before the request is executed, but cannot do so because shouldOverrideUrlLoading does not fire.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants