Note that there are some explanatory texts on larger screens.

plurals
  1. POPhoneGap detecting specific URL in iOS5 UIWebView
    primarykey
    data
    text
    <p>I am using PhoneGap for an iOS project and everything is working except I want to detect a click of the logout link in our web app and intercept it with local logout logic. I am able to detect the logout link, but the logic below ALSO thinks it is the logout page when about:blank fires in PhoneGap's UIWebView. Any ideas what I'm doing wrong?</p> <pre><code>- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSURL *url = [request URL]; // If we detect the logout.jsp we need to go back to the login form and reset the credentials if ([[url path] rangeOfString:@"logout.jsp"].location == NSNotFound) { if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) { return YES; } else { return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ]; } } else { // have PhoneGap go back to index page NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"www/index" ofType:@"html"]; NSURL *url = [NSURL fileURLWithPath:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [theWebView loadRequest:requestObj]; return NO; } } </code></pre> <p>EDIT:</p> <p>I haven't solved why this is happening, so for now I have added this workaround in the main else clause:</p> <pre><code>if ([[url path] rangeOfString:@"about:blank"].location != NSNotFound) { return YES; } </code></pre> <p>The bounty will go to someone who can figure out why I even need that workaround when the initial IF is only checking for the logout.jsp string in the url and about:blank should never match that, but does in this case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload