user1960169
user1960169

Reputation: 3653

How to capture UIWebView redirecting url in iOS

I have an UIWebView in my app. It loads some html page. In that html page has a button. When user click on that it redirects to another html page.If that new page is success page I want to do something in my app. How can I identify the redirecting url within my app.

Please help me. Thanks

Upvotes: 0

Views: 3287

Answers (2)

Leo
Leo

Reputation: 24714

You can get the url in this delegate method shouldStartLoadWithRequest,for example

- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
            navigationType:(UIWebViewNavigationType)navigationType{
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
    if ([request.URL.path isEqualToString:@"Your successurl"]) {
        //Do something
    }
}
    return true;
}

Upvotes: 0

Vijay
Vijay

Reputation: 801

UIWebView have delegate methods to get the URL what it loads.

-(void)webViewDidStartLoad:(UIWebView *)webView
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

Try these methods

Upvotes: 4

Related Questions