Explorar el Código

修改默认ua

xiongzhu hace 7 años
padre
commit
cafa8b6f1e
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      model/Classes/Application/AppDelegate.m

+ 5 - 1
model/Classes/Application/AppDelegate.m

@@ -41,7 +41,11 @@ NSString *NTESNotificationLogout = @"NTESNotificationLogout";
     // Override point for customization after application launch.
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     self.window.backgroundColor = [UIColor whiteColor];
-
+    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
+    NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
+    NSString *newUserAgent = [userAgent stringByAppendingString:@" chmo"];//自定义需要拼接的字符串
+    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];
+    [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
 
     NSString *appKey = @"c545b95fd20d5a20d0d1220dc6831e4d";
     NIMSDKOption *option = [NIMSDKOption optionWithAppKey:appKey];