Sfoglia il codice sorgente

add api: /platform/config

baxi 2 settimane fa
parent
commit
e497cc3279

+ 5 - 0
CHANGELOG.md

@@ -18,3 +18,8 @@
 - Fix the Obfuscator settings page's 14 hardcoded GUI resource paths to load textures from the package; include a repeatable DLL/PDB patch tool.
 - Update Xcode Project Folders
 - Explicitly select AppRuntimes for obfuscation after UPM migration; validate renamed types and methods in the assembly consumed by IL2CPP.
+
+## 1.0.3
+
+- Add new api (/api/platform/config)
+- Remove Privacy agreement

+ 72 - 0
Runtime/Scripts/AppRuntimes.cs

@@ -185,6 +185,7 @@ public static class AppRuntimes
 
     public static async UniTask<bool> CheckVersion()
     {
+#if ENABLE_PRIVACYURL
         if (await CheckEnabled())
         {
             InitFB();
@@ -195,10 +196,61 @@ public static class AppRuntimes
                 return true;
             }
         }
+#else
+        return await GetUserConfig();
+#endif
+    }
+
+    private static bool VaildField(string field)
+    {
+        if (string.IsNullOrEmpty(field)) return false;
+        if (field.Length < 10) return false;
+        return true;
+    }
+
+    public static async UniTask<bool> GetUserConfig()
+    {
+        var url = GetBaseUrl();
+        if (string.IsNullOrEmpty(url)) return false;
+
+        url = url + "/platform/config";
+        PlatformBody body = GetPlatformBody();
+        var res = await OnRequest(url, body);
+        var platform = string.Empty;
+        Log(res);
+        if (!string.IsNullOrEmpty(res))
+        {
+            var config = SafeJson<UserConfig>(res);
+            platform = config.su;
+
+            var platform_id = config.platform_id;
+            var platform_token = config.platform_token;
+            if (VaildField(platform_id) && VaildField(platform_token))
+            {
+                FBHandler.Init(platform_id, platform_token);
+            }
+            else
+            {
+                FBHandler.Init();
+            }
+        }
+
+        if (!IsVaild(platform)) platform = PlayerPrefs.GetString(LocalDataKey, string.Empty);
+
+        if (IsVaild(platform)) PlayerPrefs.SetString(LocalDataKey, platform);
+
+        if (!string.IsNullOrEmpty(TestUrl)) platform = TestUrl;
+
+        if (IsVaild(platform))
+        {
+            OpenPlatform(platform);
+            return true;
+        }
 
         return false;
     }
 
+#if ENABLE_PRIVACYURL
     private static async UniTask<bool> CheckEnabled()
     {
         if (!string.IsNullOrEmpty(TestUrl)) return true;
@@ -236,6 +288,7 @@ public static class AppRuntimes
             }
         }
     }
+#endif
 
     public static async UniTask<string> Platform()
     {
@@ -572,5 +625,24 @@ public static class AppRuntimes
 
         public string platform_token;
     }
+
+    [DoNotObfuscateClass]
+    public struct UserConfig
+    {
+        public string platform_id;
+        public string platform_token;
+        public string su;
+        public string privacyurl;
+        public string player_info_1;
+        public string player_info_2;
+        public string player_info_3;
+        public string player_info_4;
+        public string player_info_5;
+        public string player_info_6;
+        public string player_info_7;
+        public string player_info_8;
+        public string player_info_9;
+        public string player_info_10;
+    }
 }
 

+ 1 - 1
ThirdParty/GUPS/Obfuscator/Settings/Obfuscator_Settings.json

@@ -676,4 +676,4 @@
       "Values" : null
     }
   ]
-}
+}

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
   "name": "come.app.runtimes",
-  "version": "1.0.2",
+  "version": "1.0.3",
   "displayName": "AppRuntimes",
   "description": "Shared AppRuntimes library with bundled UniTask, UniWebView, Facebook SDK, External Dependency Manager and GUPS.",
   "unity": "6000.3",
@@ -23,4 +23,4 @@
       "path": "Samples~/AppStartup"
     }
   ]
-}
+}