private void Awake() { if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer) { return; } print("ShareSDK Awake"); Type type = devInfo.GetType(); Hashtable platformConfigs = new Hashtable(); FieldInfo[] devInfoFields = type.GetFields(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); int platformId = (int)info.GetType().GetField("type").GetValue(info); FieldInfo[] fields = info.GetType().GetFields(); Hashtable table = new Hashtable(); foreach (FieldInfo field in fields) { if ("type".EndsWith(field.Name)) { continue; } else if ("Enable".EndsWith(field.Name) || "ShareByAppClient".EndsWith(field.Name) || "BypassApproval".EndsWith(field.Name)) { table.Add(field.Name, Convert.ToString(field.GetValue(info)).ToLower()); } else { table.Add(field.Name, Convert.ToString(field.GetValue(info))); } } platformConfigs.Add(platformId, table); } #if UNITY_ANDROID shareSDKUtils = new AndroidImpl(gameObject); #elif UNITY_IPHONE shareSDKUtils = new iOSImpl(gameObject); #endif shareSDKUtils.InitSDK(appKey); shareSDKUtils.SetPlatformConfig(platformConfigs); }
//shareSDK private void checkPlatforms(DevInfoSet devInfo) { Type type = devInfo.GetType(); FieldInfo[] devInfoFields = type.GetFields(); Hashtable enablePlatforms = new Hashtable(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); if (info.Enable) { int platformId = (int)info.GetType().GetField("type").GetValue(info); string appkey = GetAPPKey(info, platformId); enablePlatforms.Add(platformId, appkey); } } var files = System.IO.Directory.GetFiles(Application.dataPath, "ShareSDK.mobpds", System.IO.SearchOption.AllDirectories); string filePath = files [0]; FileInfo projectFileInfo = new FileInfo(filePath); if (projectFileInfo.Exists) { StreamReader sReader = projectFileInfo.OpenText(); string contents = sReader.ReadToEnd(); sReader.Close(); sReader.Dispose(); Hashtable datastore = (Hashtable)MiniJSON.jsonDecode(contents); if (datastore.ContainsKey("ShareSDKPlatforms")) { datastore["ShareSDKPlatforms"] = enablePlatforms; } else { datastore.Add("ShareSDKPlatforms", enablePlatforms); } var json = MiniJSON.jsonEncode(datastore); StreamWriter sWriter = new StreamWriter(filePath); sWriter.WriteLine(json); sWriter.Close(); sWriter.Dispose(); } }
public void init() { Type type = devInfo.GetType(); Hashtable platformConfigs = new Hashtable(); FieldInfo[] devInfoFields = type.GetFields(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); if (info == null) { continue; } int platformId = (int)info.GetType().GetField("type").GetValue(info); FieldInfo[] fields = info.GetType().GetFields(); Hashtable table = new Hashtable(); foreach (FieldInfo field in fields) { if ("type".EndsWith(field.Name)) { continue; } else if ("Enable".EndsWith(field.Name) || "ShareByAppClient".EndsWith(field.Name) || "BypassApproval".EndsWith(field.Name) || "WithShareTicket".EndsWith(field.Name)) { table.Add(field.Name, Convert.ToString(field.GetValue(info)).ToLower()); } else { table.Add(field.Name, Convert.ToString(field.GetValue(info))); } } platformConfigs.Add(platformId, table); } #if UNITY_ANDROID shareSDKUtils = new AndroidImpl(gameObject); shareSDKUtils.InitSDK(appKey, appSecret); #elif UNITY_IPHONE shareSDKUtils = new iOSImpl(gameObject); #endif shareSDKUtils.SetPlatformConfig(platformConfigs); }
// public EventHandler showAutoInfoHandler; void Awake() { print("ShareSDK Awake"); Type type = devInfo.GetType(); Hashtable platformConfigs = new Hashtable(); FieldInfo[] devInfoFields = type.GetFields(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); Type type0 = info.GetType(); int platformId = (int)type0.GetField("type").GetValue(info); //int platformId = (int) info.GetType().GetField("type").GetValue(info); FieldInfo[] fields = info.GetType().GetFields(); Hashtable table = new Hashtable(); foreach (FieldInfo field in fields) { if ("type".EndsWith(field.Name)) { continue; } else if ("Enable".EndsWith(field.Name) || "ShareByAppClient".EndsWith(field.Name) || "BypassApproval".EndsWith(field.Name)) { table.Add(field.Name, Convert.ToString(field.GetValue(info)).ToLower()); } else { table.Add(field.Name, Convert.ToString(field.GetValue(info))); } } platformConfigs.Add(platformId, table); } #if UNITY_ANDROID shareSDKUtils = new AndroidImpl(gameObject); #elif UNITY_IOS shareSDKUtils = new iOSImpl(gameObject); #endif Debug.Log("ShareSDK:" + appKey); shareSDKUtils.InitSDK(appKey); shareSDKUtils.SetPlatformConfig(platformConfigs); }
private void Awake() { if (Application.isEditor) { return; } MonoBehaviour.print("ShareSDK Awake"); Type type = this.devInfo.GetType(); Hashtable hashtable = new Hashtable(); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; for (int i = 0; i < array.Length; i++) { FieldInfo fieldInfo = array[i]; DevInfo devInfo = (DevInfo)fieldInfo.GetValue(this.devInfo); int num = (int)devInfo.GetType().GetField("type").GetValue(devInfo); FieldInfo[] fields2 = devInfo.GetType().GetFields(); Hashtable hashtable2 = new Hashtable(); FieldInfo[] array2 = fields2; for (int j = 0; j < array2.Length; j++) { FieldInfo fieldInfo2 = array2[j]; if (!"type".EndsWith(fieldInfo2.Name)) { if ("Enable".EndsWith(fieldInfo2.Name) || "ShareByAppClient".EndsWith(fieldInfo2.Name) || "BypassApproval".EndsWith(fieldInfo2.Name)) { hashtable2.Add(fieldInfo2.Name, Convert.ToString(fieldInfo2.GetValue(devInfo)).ToLower()); } else { hashtable2.Add(fieldInfo2.Name, Convert.ToString(fieldInfo2.GetValue(devInfo))); } } } hashtable.Add(num, hashtable2); } this.shareSDKUtils = new AndroidImpl(base.gameObject); this.shareSDKUtils.InitSDK(this.appKey); this.shareSDKUtils.SetPlatformConfig(hashtable); }
void Awake() { print("ShareSDK Awake"); Type type = devInfo.GetType(); Hashtable platformConfigs = new Hashtable(); FieldInfo[] devInfoFields = type.GetFields(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); int platformId = (int)info.GetType().GetField("type").GetValue(info); FieldInfo[] fields = info.GetType().GetFields(); Hashtable table = new Hashtable(); foreach (FieldInfo field in fields) { if ("type".EndsWith(field.Name)) { continue; } else if ("Enable".EndsWith(field.Name)) { table.Add(field.Name, Convert.ToString(field.GetValue(info)).ToLower()); } else { table.Add(field.Name, Convert.ToString(field.GetValue(info))); } } platformConfigs.Add(platformId, table); } string appKey = (string)appkey.GetType().GetField("appKey").GetValue(appkey); #if UNITY_ANDROID shareSDKUtils = new AndroidUtils(gameObject); #elif UNITY_IPHONE shareSDKUtils = new iOSUtils(gameObject); #endif shareSDKUtils.RigisterAppAndSetPlatformConfig(appKey, platformConfigs); }
private string GetValueByName(DevInfo devInfoField, string valueName) { return((string)devInfoField.GetType().GetField(valueName).GetValue(devInfoField)); }
//shareSDK private void checkPlatforms(DevInfoSet devInfo) { Type type = devInfo.GetType(); FieldInfo[] devInfoFields = type.GetFields(); Hashtable enablePlatforms = new Hashtable(); foreach (FieldInfo devInfoField in devInfoFields) { DevInfo info = (DevInfo)devInfoField.GetValue(devInfo); if (info.Enable) { int platformId = (int)info.GetType().GetField("type").GetValue(info); string appkey = GetAPPKey(info, platformId); enablePlatforms.Add(platformId, appkey); if (info.GetType().GetField("app_universalLink") != null) { string app_universalLink = GetValueByName(info, "app_universalLink"); if (app_universalLink != null && app_universalLink.Length > 0) { app_universalLink = app_universalLink.Trim().TrimEnd('/'); if (app_universalLink.Contains("://")) { string[] links = app_universalLink.Split(new[] { "://" }, StringSplitOptions.None); app_universalLink = "applinks:" + links[1]; associatedDomains.Add(app_universalLink); } else { if (app_universalLink.Contains(":")) { associatedDomains.Add(app_universalLink); } else { app_universalLink = "applinks:" + app_universalLink; associatedDomains.Add(app_universalLink); } } } } } } var files = System.IO.Directory.GetFiles(Application.dataPath, "ShareSDK.mobpds", System.IO.SearchOption.AllDirectories); string filePath = files [0]; FileInfo projectFileInfo = new FileInfo(filePath); if (projectFileInfo.Exists) { StreamReader sReader = projectFileInfo.OpenText(); string contents = sReader.ReadToEnd(); sReader.Close(); sReader.Dispose(); Hashtable datastore = (Hashtable)MiniJSON.jsonDecode(contents); if (datastore.ContainsKey("ShareSDKPlatforms")) { datastore["ShareSDKPlatforms"] = enablePlatforms; } else { datastore.Add("ShareSDKPlatforms", enablePlatforms); } //Debug.LogWarning("======================="); Debug.LogWarning(associatedDomains.ToArray()); //if (associatedDomains.Count > 0) //{ var associatedDomains_t = associatedDomains.Distinct(); if (datastore.ContainsKey("AssociatedDomains")) { datastore["AssociatedDomains"] = associatedDomains_t.ToArray(); } else { datastore.Add("AssociatedDomains", associatedDomains_t.ToArray()); } //} var json = MiniJSON.jsonEncode(datastore); StreamWriter sWriter = new StreamWriter(filePath); sWriter.WriteLine(json); sWriter.Close(); sWriter.Dispose(); } }