From 2d4e349cd7f9f6b4a6fe005fd02ccfa6d6160f07 Mon Sep 17 00:00:00 2001
From: MacBuilder <MacBuilder@secondworld.com>
Date: 星期四, 23 八月 2018 21:16:08 +0800
Subject: [PATCH] Fixed IOS SDK 逻辑增加读取差异化配置逻辑

---
 Assets/Plugins/iOS/The2thWorldSDK/UniversalSDK.mm |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/Assets/Plugins/iOS/The2thWorldSDK/UniversalSDK.mm b/Assets/Plugins/iOS/The2thWorldSDK/UniversalSDK.mm
index 6e88c97..ef4d582 100644
--- a/Assets/Plugins/iOS/The2thWorldSDK/UniversalSDK.mm
+++ b/Assets/Plugins/iOS/The2thWorldSDK/UniversalSDK.mm
@@ -34,6 +34,9 @@
 
 -(void) Init
 {
+    NSString* _configPath = [[NSBundle mainBundle] pathForResource:@"The2thWorldSDKConfig" ofType:@"plist"];
+    NSMutableDictionary *_configDict = [[NSMutableDictionary alloc] initWithContentsOfFile:_configPath];
+    
     UIDevice *_device = [UIDevice currentDevice];
     _device.batteryMonitoringEnabled = true;
     
@@ -72,7 +75,7 @@
     [self SendMessageToUnity:_dict];
     
     // 鑷敱sdk鍒濆鍖�
-    [self FreeSDKInit];
+    [self FreeSDKInit:_configDict[@"FreeSDK_AppID"]];
     
     // 鍙戦�佷釜鎺╥d
     [_dict removeAllObjects];
@@ -81,10 +84,14 @@
     [self SendMessageToUnity:_dict];
     
     // 鐑簯鍒濆鍖�
-    [Tracking initWithAppKey:@"3c3724431309474be938e0b64d4ad74f" withChannelId:@"_default_"];
+    [Tracking initWithAppKey:_configDict[@"TrackingIO_AppKey"]
+               withChannelId:@"_default_"];
     
     // 浠婃棩澶存潯
-    [TTTracker startWithAppID:@"151709" channel:@"ios-snqxz" appName:@"灏戝勾濂囦緺浼�"];
+    NSDictionary* _infoDictionary = [[NSBundle mainBundle] infoDictionary];
+    [TTTracker startWithAppID:_configDict[@"TTTrack_AppID"]
+                      channel:@"ios-snqxz"
+                      appName:[_infoDictionary objectForKey:@"CFBundleDisplayName"]];
     
     // 鍙戦�佸垵濮嬪寲瀹屾垚
     [_dict removeAllObjects];
@@ -103,8 +110,8 @@
     }
 }
 
--(void) FreeSDKInit {
-    [FreeSDK initSDKWithAppId:FreeSDK_AppID withSDKBlock:^(YLSDKType type, NSString *msg) {
+-(void) FreeSDKInit:(NSString*)freeSdkAppID {
+    [FreeSDK initSDKWithAppId:freeSdkAppID withSDKBlock:^(YLSDKType type, NSString *msg) {
         NSMutableDictionary *_dict = NULL;
         switch (type) {
             case YLSDKTypeInitSuccess:
@@ -265,7 +272,10 @@
 }
 
 -(void)JPushInit:(NSDictionary*)launchOptions {
-    NSLog(@"JPushInit Finished.");
+    
+    NSString* _configPath = [[NSBundle mainBundle] pathForResource:@"The2thWorldSDKConfig" ofType:@"plist"];
+    NSMutableDictionary *_configDict = [[NSMutableDictionary alloc] initWithContentsOfFile:_configPath];
+    
     JPUSHRegisterEntity *_entity = [[JPUSHRegisterEntity alloc] init];
     _entity.types = JPAuthorizationOptionAlert | JPAuthorizationOptionBadge | JPAuthorizationOptionSound;
     if([[UIDevice currentDevice].systemVersion floatValue] > 8.0){
@@ -274,8 +284,8 @@
     [JPUSHService registerForRemoteNotificationConfig:_entity
                                              delegate:self];
     [JPUSHService setupWithOption:launchOptions
-                           appKey:JPush_AppKey
-                          channel:JPush_Channel
+                           appKey:_configDict[@"JPush_AppKey"]
+                          channel:@"develop"
                  apsForProduction:JPush_IsProduction
             advertisingIdentifier:nil];
 }
@@ -346,7 +356,11 @@
             [UIPasteboard generalPasteboard].string = _dict[@"content"];
             break;
         case U2S_FreePlatformInit:
-            [self FreeSDKInit];
+        {
+            NSString* _configPath = [[NSBundle mainBundle] pathForResource:@"The2thWorldSDKConfig" ofType:@"plist"];
+            NSMutableDictionary *_configDict = [[NSMutableDictionary alloc] initWithContentsOfFile:_configPath];
+            [self FreeSDKInit:_configDict[@"FreeSDK_AppID"]];
+        }
             break;
         case U2S_MakeKeyAndVisible:
         {

--
Gitblit v1.8.0