Links to UIWebView opening in Safari

I want to open the iTunes link in my web browser, but when the webView launches the page, it redirects to the Safari browser. There the URL opens, but I want it to open in my web browser.

- (void)viewDidLoad { NSString *urlAddress = @"http://itunes.apple.com/us/app/foodcheck-traffic-light-nutrition/id386368933?mt=8"; //Create a URL object. NSURL *url = [NSURL URLWithString:urlAddress]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [webView loadRequest:requestObj]; [super viewDidLoad]; } 

Please suggest a way to solve this problem.

+6
source share
3 answers

You can try to register download requests at application startup. Perhaps the apple automatically changes http:// to itms-apps or http://phobos or something in that direction. If so, then you can lock the load when it is called using something like this:

 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; { NSURL *loadURL = [[request URL] retain]; NSLog(@"%@",loadURL); if([[loadURL absoluteString] hasPrefix:@"http://"]) { [loadURL release]; return TRUE; } [loadURL release]; return FALSE; } 

Good luck. I am curious to know what ultimately works.

+1
source

Note from Apple-Q reference documents: How to launch the App Store from an iPhone app? Also, how can I link to my app in the store?

Note. If you have iTunes links inside the UIWebView, you can use this after intercepting the links with the -[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate.

+1
source

Not sure if it ever worked out, but it works well for me:

 NSString *responseString = [NSString stringWithContentsOfURL:myURL]; [self.webView loadHTMLString:responseString baseURL: nil)]; 
0
source

Source: https://habr.com/ru/post/889073/


All Articles