123456789101112131415161718192021222324252627282930 |
- //
- // FKWebviewUtil.m
- // FirstLink
- //
- // Created by ascii on 16/4/26.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKWebviewUtil.h"
- #import "FKReachabilityUtil.h"
- @implementation FKWebviewUtil
- + (void)configUserAgent {
- UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
- NSString* userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
- NSRange range = [userAgent rangeOfString:@"firstlinkapp"];
- if (range.length > 0) {
- userAgent = [userAgent substringToIndex:range.location - 1];
- }
-
- NSString *uaString = [NSString stringWithFormat:@"%@ firstlinkapp/%@ NetType/%@"
- , userAgent
- , [SystemUtil applicationVersion]
- , [FKReachabilityUtil sharedInstance].networkType4UA];
- [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent" : uaString, @"User-Agent" : uaString}];
- }
- @end
|