在原生app內嵌入h5,出現(xiàn)了運營商的廣告(注意,在wifi情況下是沒有廣告的,只有在流量的情況下才會出現(xiàn)廣告)
在網(wǎng)上看了解決辦法
1.比較靠譜的是https
2.另外一種方法是修改webView的navigator.userAgent
修改方法如下
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *newUserAgent = [userAgent stringByAppendingString:@"native_iOS_(這個地方為隨意字符串,隨意延長)3601234567891011121314151617181920212223242526272829303132333435363"];//自定義需要拼接的字符串
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
經過驗證,第二種方法能用。延長到512個字符的時候還不能使用,那就再試試延長到1024個