public void OnPostGenerateGradleAndroidProject(string basePath) { if (EditorUserBuildSettings.selectedBuildTargetGroup != BuildTargetGroup.Android) { return; } var settings = WeChatLoader.GetSettings(); if (settings == null) { return; } if (!settings.m_GenerateCallbackCode) { return; } var androidManifest = new WeChatAndroidManifest(GetManifestPath(basePath)); // Modify android manifest file to include the activity for customtab based WeChat Sign-in androidManifest.AddSignInWithWeChatActivity(); androidManifest.Save(); }
public void OnPostGenerateGradleAndroidProject(string path) { if (EditorUserBuildSettings.selectedBuildTargetGroup != BuildTargetGroup.Android) { return; } var settings = WeChatLoader.GetSettings(); if (settings == null) { return; } if (settings.m_GenerateCallbackCode) { GenerateAndroidCallbackCode(path); } }
public void OnPreprocessBuild(BuildReport report) { // Clean and reset settings before builds to make sure we don't // pollute later builds with assets that may be unnecessary or are outdated. CleanOldSettings(); WeChatLoaderSettings settings = WeChatLoader.GetSettings(); if (settings == null) { return; } Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets(); if (!preloadedAssets.Contains(settings)) { var assets = preloadedAssets.ToList(); assets.Add(settings); PlayerSettings.SetPreloadedAssets(assets.ToArray()); } }
public static void ChangeXCodePlist(BuildTarget buildTarget, string pathToBuildProject) { if (buildTarget != BuildTarget.iOS) { return; } WeChatLoaderSettings settings = WeChatLoader.GetSettings(); if (settings == null) { return; } var appId = settings.m_AppID; if (string.IsNullOrEmpty(appId)) { return; } // Info.plist var plistPath = pathToBuildProject + "/Info.plist"; var plist = new PlistDocument(); plist.ReadFromString(File.ReadAllText(plistPath)); // ROOT var rootDict = plist.root; const string urlTypesKey = "CFBundleURLTypes"; PlistElementArray urlTypes = (PlistElementArray)rootDict[urlTypesKey]; if (null == urlTypes) { urlTypes = rootDict.CreateArray(urlTypesKey); } // Add URLScheme for WeChat var wxUrl = urlTypes.AddDict(); wxUrl.SetString("CFBundleTyeRole", "Editor"); wxUrl.SetString("CFBundleURLName", "weixin"); wxUrl.SetString("CFBundleURLSchemes", appId); var wxUrlScheme = wxUrl.CreateArray("CFBundleURLSchemes"); wxUrlScheme.AddString(appId); //whitelist WeChat w const string queriesSchemesKey = "LSApplicationQueriesSchemes"; PlistElementArray queriesSchemes = (PlistElementArray)rootDict[queriesSchemesKey]; if (null == queriesSchemes) { queriesSchemes = rootDict.CreateArray("LSApplicationQueriesSchemes"); } queriesSchemes.AddString("wechat"); queriesSchemes.AddString("weixin"); queriesSchemes.AddString(val: appId); File.WriteAllText(plistPath, plist.WriteToString()); }