-1

Webview delegate shouldstartloadwithrequest recieves url from HTML and when i check the request everything is been converted to small letters:

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[request URL] absoluteString];
        if ([link hasPrefix:@"playSound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}

The line that make the problem is

NSString *link = [[request URL] absoluteString];

Before I got an unmodified copy of the clicked link. In iOS3 and iOS4 it is still the same. But on iOS5 it is converted to lowercase only. The next Line

if ([link hasPrefix:@"playSound:"]) {

never becomes true. So I had to change the code to

- (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest:(NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType {
    // Only do something if a link has been clicked
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        NSString *link = [[[request URL] absoluteString] lowercaseString];
        if ([link hasPrefix:@"playsound:"]) {
            [PlayAudio playAudio: [link substringFromIndex:10]];
            return NO;
        }
    }
    return YES;
}
Prashant Nikam
  • 2,253
  • 4
  • 17
  • 29
Mahesh S
  • 9
  • 1

2 Answers2

1

This was a change made as part of the upgrade to safari in iOS 5 and is consistent with the spec for URL's. The URL scheme will always be converted to lower case.

(I had to fix a lot of code because of this change)

Mike M
  • 4,358
  • 1
  • 28
  • 48
0
if ([link hasPrefix:@"playsound:"] ||[link hasPrefix:@"playSound:"] )
{
    [PlayAudio playAudio: [link substringFromIndex:10]];
        return NO;
}
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
  • But the problem is that im getting the encoded value in the request field. As i recieve everything in small i cant decode it. When i decode it im getting as nil.. – Mahesh S Aug 01 '13 at 09:26