I am trying to check the current URL in a UIWebView with the following code:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
NSString *currentURL = webView.request.URL.absoluteString;
NSLog(@"Current URL: %@", currentURL);
NSString *loginpage = @"file:///var/mobile/Applications/652BAC0C-DEAE-4695-9195-BE617B9D5106/School%20VLE%20Business.app/login.html";
if([currentURL isEqualToString:loginpage])
{
NSLog(@"Inputting user details...");
NSString *result;
result = [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"$('#usernamefield').val('%@');", username]];
result = [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"$('#passwordfield').val('%@');", password]];
result = [webView stringByEvaluatingJavaScriptFromString:@"$('#submitbutton').click();"];
NSLog(@"Logged in!");
}
}
But the code in the local URL (652BAC0C-DEAE-4695-9195-BE617B9D5106 for me) isn't going to be the same for everybody, so how can I do the same check but without the long code?