Skip to content

Instantly share code, notes, and snippets.

@vargon
Created May 4, 2012 13:20
Show Gist options
  • Save vargon/2594775 to your computer and use it in GitHub Desktop.
Save vargon/2594775 to your computer and use it in GitHub Desktop.
Handling "myscheme" in Objective C
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *scheme = [[[request URL] scheme] lowercaseString];
if([scheme isEqualToString:@"myscheme"]) {
// Pull the encoded JSON string out of the querystring
// Decode the string, convert JSON string into usable object
// Handle the message
// Return NO to prevent the webview from navigating
return NO;
}
// Allow normal webview navigation
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment