修改User-Agent的方法

2018-10-18  本文已影响171人  FingerStyle

- (void)modifyUserAgent {

    //修改UA为统一UA

    NSString *oldAgent = [self stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

    NSLog(@"old agent :%@", oldAgent);

    //add my info to the new agent

    NSString*newAgent = [QMParamsHelper commonUserAgent:oldAgent];

    NSLog(@"new agent :%@", newAgent);

    MEMORY_VALUE.userAgent= newAgent;

    //regist the new agent

    NSDictionary *dictionnary = [[NSDictionary alloc] initWithObjectsAndKeys:newAgent, @"UserAgent", nil];

    [[NSUserDefaults standardUserDefaults] registerDefaults:dictionnary];

}

上一篇 下一篇

猜你喜欢

热点阅读