Esempio n. 1
0
        //public OnLoopShareCallBack onLoopsharecallback;
#endif
        void 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) || "WithShareTicket".EndsWith(field.Name))
                    {
                        table.Add(field.Name, Convert.ToString(field.GetValue(info)).ToLower());

                        //Debug.Log("======================platformConfigs table info 1:" + Convert.ToString(field.GetValue(info)).ToLower());
                    }
                    else
                    {
                        table.Add(field.Name, Convert.ToString(field.GetValue(info)));
                        //Debug.Log("======================platformConfigs table info 2:" + Convert.ToString(field.GetValue(info)));
                    }
                }

                //Debug.Log("======================platformConfigs platformId:" + platformId);
                //Debug.Log("======================platformConfigs table:" + table);
                platformConfigs.Add(platformId, table);
            }
            //Debug.Log("======================platformConfigs:" + platformConfigs);
#if UNITY_ANDROID
            shareSDKUtils = new AndroidImpl(gameObject);
            shareSDKUtils.InitSDK(appKey, appSecret);

            //add listener for loopshare
            shareSDKUtils.PrepareLoopShare();
            shareSDKUtils.setChannelId();
#elif UNITY_IPHONE
            shareSDKUtils = new iOSImpl(gameObject);
#endif

            shareSDKUtils.SetPlatformConfig(platformConfigs);
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化shareSDK
        /// </summary>
        public void InitializeShareSDK()
        {
            if (initialized)
            {
                return;
            }

            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);
            shareSDKUtils.InitSDK(appKey, appSecret);
#elif UNITY_IPHONE
            shareSDKUtils = new iOSImpl(gameObject);
#endif

            initialized = true;

            shareSDKUtils.SetPlatformConfig(platformConfigs);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        //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();
            }
        }
Esempio n. 5
0
        // 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);
        }
Esempio n. 6
0
        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);
        }
        //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();
            }
        }