美文网首页
H5中的运营商广告

H5中的运营商广告

作者: h小 | 来源:发表于2017-05-11 10:58 被阅读36次

    在原生app内嵌入h5,出现了运营商的广告(注意,在wifi情况下是没有广告的,只有在流量的情况下才会出现广告)
    在网上看了解决办法
    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个

    相关文章

      网友评论

          本文标题:H5中的运营商广告

          本文链接:https://www.haomeiwen.com/subject/ghqotxtx.html