Question

I am using OAuth2 to log into Instagram. To do this, you need a webview, which loads a webpage with login fields and login button.

How do I detect if the login button was pressed in the webview so that I can dismiss the modal that the webview is presented in?

Is there any way to catch the request after I press login in the webview? Can I use isViewLoaded?

Was it helpful?

Solution

I use this to detect whether user logins successfully:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
 NSString *urlStr = LOGIN_OK_URL;
 NSString *urlStr1 = LOGIN_OK_URL_1;
 if([URLString hasPrefix:urlStr] || [URLString hasPrefix:urlStr1]){
   // login successfully, dismiss this view 
 } else if ([URLString hasPrefix:URL_LOGIN_CANCEL] == 1 || [URLString isEqualToString:URL_LOGOUT_CANCEL]) {
   // user presses cancel button, dismiss this view
 }
   // processing login page
 return YES

}

Detect the login button was pressed: how to intercept Button click inside UIWebview on IOS?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top