#define AgreementName @"hybrid://nativechannel/"
#pragma mark - webview delegate
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString*requestUrl=[selfURLDecodedString:[requestURL].absoluteString];
//獲取分享json
if([requestUrlhasPrefix:AgreementName])
{
NSString*urlData=[requestUrlsubstringFromIndex:AgreementName.length];
@try{
idjsonData=[urlDataobjectFromJSONString]; ?//此方法為jsonKit自帶的方法
if([jsonDataisKindOfClass:[NSDictionaryclass]])
{
NSDictionary* dic = (NSDictionary*)jsonData;
NSLog(@"json dic == %@",dic);
}
}
@catch(NSException *exception) {
}
@finally{
}
returnNO;
}
returnYES;
}
-(NSString*)URLDecodedString:(NSString*)str
{
NSString*decodedString=(__bridge_transferNSString*)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (__bridgeCFStringRef)str,CFSTR(""),CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
returndecodedString;
}