com.xd.sdk.common 6.26.2 → 6.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Android/AndroidGradleProjectConfig.cs +66 -0
- package/Editor/Android/AndroidGradleProjectConfig.cs.meta +11 -0
- package/Editor/Android/VersionCatalog.cs +41 -0
- package/Editor/Android/VersionCatalog.cs.meta +3 -0
- package/Editor/Android/XDAndroidProjectProcessor.cs +323 -0
- package/Editor/Android/XDAndroidProjectProcessor.cs.meta +11 -0
- package/Editor/Android.meta +8 -0
- package/Editor/XDConfigModel.cs +59 -0
- package/Editor/XDConfigModel.cs.meta +1 -1
- package/Editor/XDGIOSCommonProcessor.cs +48 -15
- package/Editor/XDGScriptHandlerProcessor.cs +55 -0
- package/Mobile/Bridge/BridgeConstants.cs +48 -0
- package/Mobile/Bridge/BridgeConstants.cs.meta +11 -0
- package/Mobile/Bridge.meta +8 -0
- package/Plugins/Android/libs/XDGCommon_6.28.0.aar +0 -0
- package/Plugins/Android/libs/{XDGCommon_6.26.2.aar.meta → XDGCommon_6.28.0.aar.meta} +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/NSError+XDG.h +3 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/TDSGlobalRouterSchemes.h +3 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDCommonSDK.h +2 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDConfigManager.h +1 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGBridgeWeb.h +2 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGConfig.h +5 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGDouYinShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGFacebookShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGInstagramShareParam.h +32 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGInstagramShareParam.h.meta +7 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGLineShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGLogger.h +13 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGPaymentLogger.h +9 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGPush.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGQQShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGShareParamBase.h +4 -2
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGTapTapShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGThirdSDKHelper.h +2 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGTikTokShareParam.h +32 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGTikTokShareParam.h.meta +7 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGTwitterShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGWeChatShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGWebParams.h +3 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGWebRequest.h +1 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGWeiboShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDGXHSShareParam.h +1 -1
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDTikTokInfo.h +18 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDTikTokInfo.h.meta +7 -0
- package/Plugins/iOS/XDCommonSDK.framework/Headers/XDVersion.h +3 -3
- package/Plugins/iOS/XDCommonSDK.framework/Info.plist +0 -0
- package/Plugins/iOS/XDCommonSDK.framework/XDCommonSDK +0 -0
- package/Plugins/iOS/XDCommonSDK.framework.meta +54 -1
- package/package.json +1 -1
- package/Plugins/Android/libs/XDGCommon_6.26.2.aar +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#if UNITY_EDITOR && UNITY_ANDROID
|
|
2
|
+
namespace XD.SDK.Common.Editor
|
|
3
|
+
{
|
|
4
|
+
public class AndroidGradleProjectConfig
|
|
5
|
+
{
|
|
6
|
+
public class Plugin
|
|
7
|
+
{
|
|
8
|
+
public string MavenCoordinates;
|
|
9
|
+
public string PluginId;
|
|
10
|
+
public string Version;
|
|
11
|
+
public bool Apply = false;
|
|
12
|
+
|
|
13
|
+
public Plugin()
|
|
14
|
+
{
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public Plugin(string mavenCoordinates, string pluginId, string version, bool apply = false)
|
|
18
|
+
{
|
|
19
|
+
MavenCoordinates = mavenCoordinates;
|
|
20
|
+
PluginId = pluginId;
|
|
21
|
+
Version = version;
|
|
22
|
+
Apply = apply;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public class MavenRepository
|
|
27
|
+
{
|
|
28
|
+
public string Url;
|
|
29
|
+
public bool AllowInsecureProtocol = false;
|
|
30
|
+
|
|
31
|
+
public MavenRepository()
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public MavenRepository(string url)
|
|
36
|
+
{
|
|
37
|
+
Url = url;
|
|
38
|
+
}
|
|
39
|
+
public MavenRepository(string url, bool allowInsecureProtocol = false)
|
|
40
|
+
{
|
|
41
|
+
|
|
42
|
+
Url = url;
|
|
43
|
+
AllowInsecureProtocol = allowInsecureProtocol;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public class Dependency
|
|
48
|
+
{
|
|
49
|
+
public string Group;
|
|
50
|
+
public string Module;
|
|
51
|
+
public string Version;
|
|
52
|
+
|
|
53
|
+
public Dependency()
|
|
54
|
+
{
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public Dependency(string group, string module, string version)
|
|
58
|
+
{
|
|
59
|
+
Group = group;
|
|
60
|
+
Module = module;
|
|
61
|
+
Version = version;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
#endif
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#if UNITY_EDITOR && UNITY_ANDROID
|
|
2
|
+
namespace XD.SDK.Common.Editor
|
|
3
|
+
{
|
|
4
|
+
public static class VersionCatalog
|
|
5
|
+
{
|
|
6
|
+
public static readonly string Kotlin = "1.7.21";
|
|
7
|
+
public static readonly string RecyclerView = "1.2.1";
|
|
8
|
+
public static readonly string AppCompat = "1.3.1";
|
|
9
|
+
public static readonly string Okhttp = "4.7.2";
|
|
10
|
+
public static readonly string Okio = "2.6.0";
|
|
11
|
+
public static readonly string Retrofit = "2.9.0";
|
|
12
|
+
public static readonly string RxJava = "2.1.1";
|
|
13
|
+
public static readonly string Gson = "2.8.6";
|
|
14
|
+
|
|
15
|
+
public static readonly string TapTapSdk = "4.5.5-alpha.4";
|
|
16
|
+
|
|
17
|
+
public static readonly string GoogleAuth = "16.0.1";
|
|
18
|
+
public static readonly string BillingClient = "7.0.0";
|
|
19
|
+
public static readonly string GoogleAdsIdentifier = "18.0.1";
|
|
20
|
+
public static readonly string FirebaseCore = "21.1.1";
|
|
21
|
+
public static readonly string FirebaseAnalytics = "21.3.0";
|
|
22
|
+
public static readonly string FirebaseMessaging = "23.4.1";
|
|
23
|
+
public static readonly string FirebaseCrashlytics = "18.6.2";
|
|
24
|
+
public static readonly string CustomTabsBrowser = "1.4.0";
|
|
25
|
+
public static readonly string Zxing = "3.5.3";
|
|
26
|
+
public static readonly string Facebook = "17.0.2";
|
|
27
|
+
public static readonly string Line = "5.8.1";
|
|
28
|
+
public static readonly string Appsflyer = "6.15.0";
|
|
29
|
+
public static readonly string AppsflyerUnityWrapper = "6.15.1";
|
|
30
|
+
public static readonly string InstallReferrer = "2.2";
|
|
31
|
+
|
|
32
|
+
public static readonly string Alipay = "15.8.32@aar";
|
|
33
|
+
public static readonly string Wechat = "6.8.0";
|
|
34
|
+
public static readonly string SinaWeibo = "12.5.0@aar";
|
|
35
|
+
public static readonly string Douyin = "0.1.9.9";
|
|
36
|
+
|
|
37
|
+
public static readonly string AliyunPush = "3.9.5";
|
|
38
|
+
public static readonly string AliyunAuxiliaryChannel = "3.9.4.1";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#endif
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
#if UNITY_EDITOR && UNITY_ANDROID
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.IO;
|
|
5
|
+
using System.Text.RegularExpressions;
|
|
6
|
+
using LC.Newtonsoft.Json;
|
|
7
|
+
using UnityEditor.Android;
|
|
8
|
+
using UnityEngine;
|
|
9
|
+
|
|
10
|
+
namespace XD.SDK.Common.Editor
|
|
11
|
+
{
|
|
12
|
+
public abstract class XDAndroidProjectProcessor : IPostGenerateGradleAndroidProject
|
|
13
|
+
{
|
|
14
|
+
protected const string UnityLibraryName = "unityLibrary";
|
|
15
|
+
|
|
16
|
+
private const string RootPatternAgp7 =
|
|
17
|
+
@"(dependencyResolutionManagement\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
18
|
+
|
|
19
|
+
private const string RootPattern =
|
|
20
|
+
@"(allprojects\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
21
|
+
|
|
22
|
+
private const string RepositoryPattern =
|
|
23
|
+
@"(repositories\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
24
|
+
|
|
25
|
+
private const string BuildscriptSyntaxPattern =
|
|
26
|
+
@"(buildscript\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
27
|
+
|
|
28
|
+
private const string PluginSyntaxPattern =
|
|
29
|
+
@"(plugins\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
30
|
+
|
|
31
|
+
private const string DependenciesPattern =
|
|
32
|
+
@"(dependencies\s*\{(?>[^{}]+|{(?<counter>)|}(?<-counter>))*(?(counter)(?!))\})";
|
|
33
|
+
|
|
34
|
+
protected XDConfigModel configModel;
|
|
35
|
+
|
|
36
|
+
public XDAndroidProjectProcessor()
|
|
37
|
+
{
|
|
38
|
+
var xdConfigPath = XDGCommonEditorUtils.GetXDConfigPath();
|
|
39
|
+
if (!File.Exists(xdConfigPath))
|
|
40
|
+
{
|
|
41
|
+
Debug.LogError("XDConfig.json 文件不存在");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
configModel = JsonConvert.DeserializeObject<XDConfigModel>(File.ReadAllText(xdConfigPath));
|
|
46
|
+
if (configModel == null)
|
|
47
|
+
{
|
|
48
|
+
Debug.LogWarning("XDConfig.json 解析失败!");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public int callbackOrder => 1100;
|
|
53
|
+
|
|
54
|
+
public void OnPostGenerateGradleAndroidProject(string path)
|
|
55
|
+
{
|
|
56
|
+
OnProcessAndroidProject(path);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected virtual void OnProcessAndroidProject(string path)
|
|
60
|
+
{
|
|
61
|
+
var rootPath = path;
|
|
62
|
+
if (rootPath.Contains(UnityLibraryName))
|
|
63
|
+
{
|
|
64
|
+
rootPath = rootPath.Substring(0, rootPath.Length - UnityLibraryName.Length);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
AddAdditionalMavenRepositories(rootPath);
|
|
68
|
+
AddAdditionalDependencies(rootPath);
|
|
69
|
+
FixExcludeNativeAarDependencies(rootPath);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private void AddAdditionalMavenRepositories(string rootPath)
|
|
73
|
+
{
|
|
74
|
+
var repositories = GenerateMavenRepositories();
|
|
75
|
+
|
|
76
|
+
var settingsGradleFilePath = Path.Combine(rootPath, "settings.gradle");
|
|
77
|
+
var buildGradleFilePath = Path.Combine(rootPath, "build.gradle");
|
|
78
|
+
var isAgp7 = DetectIsAgp7(settingsGradleFilePath);
|
|
79
|
+
|
|
80
|
+
var additionalMavenRepoContent = PrepareAdditionalContent(
|
|
81
|
+
repositories,
|
|
82
|
+
r => r.AllowInsecureProtocol
|
|
83
|
+
? $" maven {{ \n allowInsecureProtocol = true \n url '{r.Url}' \n }}"
|
|
84
|
+
: $" maven {{ url '{r.Url}' }}",
|
|
85
|
+
isAgp7 ? settingsGradleFilePath : buildGradleFilePath
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// 添加 Maven 仓库到相应文件
|
|
89
|
+
if (isAgp7 && File.Exists(settingsGradleFilePath))
|
|
90
|
+
{
|
|
91
|
+
ModifyFileContent(settingsGradleFilePath,
|
|
92
|
+
content =>
|
|
93
|
+
{
|
|
94
|
+
return ReplaceInPattern(content, RootPatternAgp7, RepositoryPattern,
|
|
95
|
+
additionalMavenRepoContent);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (File.Exists(buildGradleFilePath))
|
|
99
|
+
{
|
|
100
|
+
ModifyFileContent(buildGradleFilePath,
|
|
101
|
+
content =>
|
|
102
|
+
{
|
|
103
|
+
return ReplaceInPattern(content, RootPattern, RepositoryPattern, additionalMavenRepoContent);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
AddAdditionalPlugins(rootPath, isAgp7);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private void AddAdditionalPlugins(string rootPath, bool isAgp7)
|
|
111
|
+
{
|
|
112
|
+
var plugins = GeneratePlugins();
|
|
113
|
+
if (plugins == null || plugins.Count == 0) return;
|
|
114
|
+
|
|
115
|
+
var buildGradleFilePath = Path.Combine(rootPath, "build.gradle");
|
|
116
|
+
if (File.Exists(buildGradleFilePath))
|
|
117
|
+
{
|
|
118
|
+
var additionalPluginsContent = PrepareAdditionalContent(
|
|
119
|
+
plugins,
|
|
120
|
+
p => isAgp7
|
|
121
|
+
? $" id '{p.PluginId}' version '{p.Version}' apply {p.Apply.ToString().ToLower()}"
|
|
122
|
+
: $" classpath '{p.MavenCoordinates}:{p.Version}'",
|
|
123
|
+
buildGradleFilePath
|
|
124
|
+
);
|
|
125
|
+
Debug.Log("XDAndroidProjectProcessor -----> additionalPluginsContent: " + additionalPluginsContent);
|
|
126
|
+
if (string.IsNullOrEmpty(additionalPluginsContent)) return;
|
|
127
|
+
|
|
128
|
+
if (isAgp7)
|
|
129
|
+
{
|
|
130
|
+
ModifyFileContent(buildGradleFilePath,
|
|
131
|
+
content =>
|
|
132
|
+
{
|
|
133
|
+
return ReplaceInPattern(content, PluginSyntaxPattern, null, additionalPluginsContent);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else
|
|
137
|
+
{
|
|
138
|
+
ModifyFileContent(buildGradleFilePath,
|
|
139
|
+
content =>
|
|
140
|
+
{
|
|
141
|
+
return ReplaceInPattern(content, BuildscriptSyntaxPattern, DependenciesPattern,
|
|
142
|
+
additionalPluginsContent);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
var launcherBuildGradleFilePath = Path.Combine(rootPath, "launcher", "build.gradle");
|
|
148
|
+
if (File.Exists(launcherBuildGradleFilePath))
|
|
149
|
+
{
|
|
150
|
+
var additionalPluginsContent = PrepareAdditionalContent(
|
|
151
|
+
plugins,
|
|
152
|
+
p => $"apply plugin: '{p.PluginId}'",
|
|
153
|
+
launcherBuildGradleFilePath
|
|
154
|
+
);
|
|
155
|
+
if (string.IsNullOrEmpty(additionalPluginsContent)) return;
|
|
156
|
+
|
|
157
|
+
ModifyFileContent(launcherBuildGradleFilePath,
|
|
158
|
+
content => { return content.Insert(0, additionalPluginsContent); });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private void AddAdditionalDependencies(string rootPath)
|
|
163
|
+
{
|
|
164
|
+
var dependencies = GenerateDependencies();
|
|
165
|
+
if (dependencies == null || dependencies.Count == 0) return;
|
|
166
|
+
|
|
167
|
+
var buildGradleFilePath = Path.Combine(rootPath, UnityLibraryName, "build.gradle");
|
|
168
|
+
if (!File.Exists(buildGradleFilePath))
|
|
169
|
+
{
|
|
170
|
+
Debug.LogError($"文件 {buildGradleFilePath} 不存在");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var additionalDependenciesContent = PrepareAdditionalContent(
|
|
175
|
+
dependencies,
|
|
176
|
+
deps => $" implementation \"{deps.Group}:{deps.Module}:{deps.Version}\"",
|
|
177
|
+
buildGradleFilePath
|
|
178
|
+
);
|
|
179
|
+
Debug.Log(
|
|
180
|
+
"XDAndroidProjectProcessor -----> additionalDependenciesContent: " + additionalDependenciesContent);
|
|
181
|
+
if (string.IsNullOrEmpty(additionalDependenciesContent)) return;
|
|
182
|
+
|
|
183
|
+
ModifyFileContent(buildGradleFilePath,
|
|
184
|
+
content =>
|
|
185
|
+
{
|
|
186
|
+
return ReplaceInPattern(content, DependenciesPattern, null, additionalDependenciesContent);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private void FixExcludeNativeAarDependencies(string rootPath)
|
|
191
|
+
{
|
|
192
|
+
var excludeNativeAarList = GenerateExcludeNativeAarList();
|
|
193
|
+
if (excludeNativeAarList == null || excludeNativeAarList.Count == 0) return;
|
|
194
|
+
|
|
195
|
+
var buildGradleFilePath = Path.Combine(rootPath, UnityLibraryName, "build.gradle");
|
|
196
|
+
if (!File.Exists(buildGradleFilePath))
|
|
197
|
+
{
|
|
198
|
+
Debug.LogError($"文件 {buildGradleFilePath} 不存在");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var gradleContentsLines = File.ReadAllLines(buildGradleFilePath);
|
|
203
|
+
for (var i = 0; i < gradleContentsLines.Length; i++)
|
|
204
|
+
{
|
|
205
|
+
var lineContent = gradleContentsLines[i];
|
|
206
|
+
foreach (var excludeAar in excludeNativeAarList)
|
|
207
|
+
{
|
|
208
|
+
if (!lineContent.Contains(excludeAar) || !lineContent.Contains("aar")) continue;
|
|
209
|
+
gradleContentsLines[i] = $"// Disable : {excludeAar}_*.aar";
|
|
210
|
+
Debug.LogFormat($"XDAndroidProjectProcessor -----> 禁用 AAR: {lineContent} 依赖");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
File.WriteAllLines(buildGradleFilePath, gradleContentsLines);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private static bool DetectIsAgp7(string settingsGradleFilePath)
|
|
218
|
+
{
|
|
219
|
+
if (!File.Exists(settingsGradleFilePath))
|
|
220
|
+
{
|
|
221
|
+
Debug.LogError("settings.gradle 文件不存在");
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
var settingsContent = File.ReadAllText(settingsGradleFilePath);
|
|
226
|
+
return Regex.IsMatch(settingsContent, RootPatternAgp7);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private static string PrepareAdditionalContent<T>(List<T> items, Func<T, string> itemFormatter,
|
|
230
|
+
string file2Check)
|
|
231
|
+
{
|
|
232
|
+
if (items == null || items.Count == 0)
|
|
233
|
+
{
|
|
234
|
+
return string.Empty;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (!File.Exists(file2Check))
|
|
238
|
+
{
|
|
239
|
+
Debug.LogError($"文件 {file2Check} 不存在");
|
|
240
|
+
return string.Empty;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
var fileContent = File.ReadAllText(file2Check);
|
|
244
|
+
|
|
245
|
+
var additionalContent = "";
|
|
246
|
+
|
|
247
|
+
foreach (var item in items)
|
|
248
|
+
{
|
|
249
|
+
var formattedItem = itemFormatter(item);
|
|
250
|
+
if (!fileContent.Contains(formattedItem))
|
|
251
|
+
{
|
|
252
|
+
additionalContent += $"{formattedItem}\n";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return additionalContent;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private static string ReplaceInPattern(string content, string outerPattern, string innerPattern,
|
|
260
|
+
string additionalContent)
|
|
261
|
+
{
|
|
262
|
+
if (string.IsNullOrEmpty(innerPattern))
|
|
263
|
+
{
|
|
264
|
+
// 如果没有内部模式,直接在外部模式的末尾添加内容
|
|
265
|
+
return Regex.Replace(content, outerPattern, match =>
|
|
266
|
+
{
|
|
267
|
+
var text = match.Value;
|
|
268
|
+
var index = text.LastIndexOf("}", StringComparison.Ordinal);
|
|
269
|
+
return text.Insert(index, additionalContent);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// 在外部模式中查找内部模式,并在内部模式的末尾添加内容
|
|
274
|
+
return Regex.Replace(content, outerPattern, outerMatch =>
|
|
275
|
+
{
|
|
276
|
+
return Regex.Replace(outerMatch.Value, innerPattern, innerMatch =>
|
|
277
|
+
{
|
|
278
|
+
var text = innerMatch.Value;
|
|
279
|
+
var index = text.LastIndexOf("}", StringComparison.Ordinal);
|
|
280
|
+
return text.Insert(index, additionalContent);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private static void ModifyFileContent(string filePath, Func<string, string> contentModifier)
|
|
286
|
+
{
|
|
287
|
+
if (!File.Exists(filePath))
|
|
288
|
+
{
|
|
289
|
+
Debug.LogError($"文件 {filePath} 不存在");
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var content = File.ReadAllText(filePath);
|
|
294
|
+
var modifiedContent = contentModifier(content);
|
|
295
|
+
|
|
296
|
+
if (content != modifiedContent)
|
|
297
|
+
{
|
|
298
|
+
File.WriteAllText(filePath, modifiedContent);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
protected virtual List<AndroidGradleProjectConfig.Plugin> GeneratePlugins()
|
|
303
|
+
{
|
|
304
|
+
return new List<AndroidGradleProjectConfig.Plugin>();
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
protected virtual List<AndroidGradleProjectConfig.MavenRepository> GenerateMavenRepositories()
|
|
308
|
+
{
|
|
309
|
+
return new List<AndroidGradleProjectConfig.MavenRepository>();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
protected virtual List<AndroidGradleProjectConfig.Dependency> GenerateDependencies()
|
|
313
|
+
{
|
|
314
|
+
return new List<AndroidGradleProjectConfig.Dependency>();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
protected virtual List<string> GenerateExcludeNativeAarList()
|
|
318
|
+
{
|
|
319
|
+
return new List<string>();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
#endif
|
package/Editor/XDConfigModel.cs
CHANGED
|
@@ -26,6 +26,8 @@ namespace XD.SDK.Common.Editor {
|
|
|
26
26
|
public WeiBoConfig weibo { get; set; }
|
|
27
27
|
public XHSConfig xhs { get; set; }
|
|
28
28
|
public DouYinConfig douyin { get; set; }
|
|
29
|
+
public AliyunConfig aliyun { get; set; }
|
|
30
|
+
public TikTokConfig tiktok { get; set; }
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
public class Adjust {
|
|
@@ -121,4 +123,61 @@ namespace XD.SDK.Common.Editor {
|
|
|
121
123
|
public class DouYinConfig {
|
|
122
124
|
public string app_id { get; set; }
|
|
123
125
|
}
|
|
126
|
+
|
|
127
|
+
public class AliyunConfig
|
|
128
|
+
{
|
|
129
|
+
public string push_key_android { get; set; }
|
|
130
|
+
public string push_secret_android { get; set; }
|
|
131
|
+
|
|
132
|
+
public AuxiliaryChannel auxiliary_channel { get; set; }
|
|
133
|
+
|
|
134
|
+
public class AuxiliaryChannel
|
|
135
|
+
{
|
|
136
|
+
public Xiaomi xiaomi { get; set; }
|
|
137
|
+
public Huawei huawei { get; set; }
|
|
138
|
+
public Honor honor { get; set; }
|
|
139
|
+
public Vivo vivo { get; set; }
|
|
140
|
+
public Oppo oppo { get; set; }
|
|
141
|
+
public Meizu meizu { get; set; }
|
|
142
|
+
|
|
143
|
+
public class Xiaomi
|
|
144
|
+
{
|
|
145
|
+
public string app_id { get; set; }
|
|
146
|
+
public string app_key { get; set; }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public class Huawei
|
|
150
|
+
{
|
|
151
|
+
public string app_id { get; set; }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public class Honor
|
|
155
|
+
{
|
|
156
|
+
public string app_id { get; set; }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public class Vivo
|
|
160
|
+
{
|
|
161
|
+
public string app_id { get; set; }
|
|
162
|
+
public string api_key { get; set; }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public class Oppo
|
|
166
|
+
{
|
|
167
|
+
public string app_key { get; set; }
|
|
168
|
+
public string app_secret { get; set; }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public class Meizu
|
|
172
|
+
{
|
|
173
|
+
public string app_id { get; set; }
|
|
174
|
+
public string app_key { get; set; }
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public class TikTokConfig
|
|
180
|
+
{
|
|
181
|
+
public string client_key { get; set; }
|
|
182
|
+
}
|
|
124
183
|
}
|
|
@@ -56,6 +56,9 @@ namespace XD.SDK.Common.Editor
|
|
|
56
56
|
proj.AddBuildProperty(unityFrameworkTarget, "OTHER_LDFLAGS", "-ObjC ");
|
|
57
57
|
proj.AddFrameworkToProject(unityFrameworkTarget, "Accelerate.framework", true);
|
|
58
58
|
proj.AddFrameworkToProject(unityFrameworkTarget, "AuthenticationServices.framework", true);
|
|
59
|
+
proj.AddFrameworkToProject(unityFrameworkTarget, "StoreKit.framework", true);
|
|
60
|
+
proj.AddFrameworkToProject(unityFrameworkTarget, "GameKit.framework", true);
|
|
61
|
+
proj.AddFileToBuild(unityFrameworkTarget, proj.AddFile("usr/lib/libresolv.tbd", "libresolv.tbd", PBXSourceTree.Sdk));
|
|
59
62
|
|
|
60
63
|
// 创建 resource 文件夹
|
|
61
64
|
var resourcePath = Path.Combine(path, "XDSDKResource");
|
|
@@ -285,36 +288,46 @@ namespace XD.SDK.Common.Editor
|
|
|
285
288
|
|
|
286
289
|
// 添加 LSApplicationQueriesSchemes
|
|
287
290
|
var items = new List<string>()
|
|
288
|
-
{
|
|
291
|
+
{
|
|
292
|
+
"tapsdk",
|
|
293
|
+
"tapiosdk",
|
|
294
|
+
"taptap",
|
|
295
|
+
|
|
296
|
+
"fbapi",
|
|
297
|
+
"fb-messenger-share-api",
|
|
298
|
+
|
|
299
|
+
"lineauth2",
|
|
300
|
+
|
|
301
|
+
"twitterauth",
|
|
302
|
+
|
|
289
303
|
"sinaweibo",
|
|
290
304
|
"weibosdk",
|
|
291
305
|
"weibosdk2.5",
|
|
292
306
|
"weibosdk3.3",
|
|
307
|
+
|
|
293
308
|
"mqqopensdkapiV2",
|
|
294
309
|
"mqq",
|
|
295
310
|
"mqqapi",
|
|
296
311
|
"tim",
|
|
297
312
|
"mqqopensdknopasteboard",
|
|
313
|
+
|
|
298
314
|
"weixin",
|
|
299
315
|
"weixinULAPI",
|
|
300
316
|
"weixinURLParamsAPI",
|
|
301
|
-
"tapsdk",
|
|
302
|
-
"tapiosdk",
|
|
303
|
-
|
|
304
|
-
"fbapi",
|
|
305
|
-
"fb-messenger-share-api",
|
|
306
|
-
|
|
307
|
-
"lineauth2",
|
|
308
|
-
|
|
309
|
-
"twitterauth",
|
|
310
317
|
|
|
311
318
|
"xhsdiscover",
|
|
312
319
|
|
|
313
320
|
"douyinopensdk",
|
|
314
321
|
"douyinliteopensdk",
|
|
315
322
|
"douyinsharesdk",
|
|
316
|
-
|
|
317
323
|
"snssdk1128",
|
|
324
|
+
|
|
325
|
+
"tiktokopensdk",
|
|
326
|
+
"tiktoksharesdk",
|
|
327
|
+
"snssdk1180",
|
|
328
|
+
"snssdk1233",
|
|
329
|
+
|
|
330
|
+
"instagram"
|
|
318
331
|
};
|
|
319
332
|
|
|
320
333
|
// 添加Scheme,用添加,不要覆盖替换!
|
|
@@ -354,6 +367,7 @@ namespace XD.SDK.Common.Editor
|
|
|
354
367
|
_plist.ReadFromString(File.ReadAllText(_plistPath));
|
|
355
368
|
var _rootDic = _plist.root;
|
|
356
369
|
|
|
370
|
+
var xdClientId = configModel.client_id;
|
|
357
371
|
var facebookId = (configModel.facebook != null ? configModel.facebook.app_id : null);
|
|
358
372
|
var facebookToken = (configModel.facebook != null ? configModel.facebook.client_token : null);
|
|
359
373
|
var taptapId = (configModel.tapsdk != null ? configModel.tapsdk.client_id : null);
|
|
@@ -369,7 +383,7 @@ namespace XD.SDK.Common.Editor
|
|
|
369
383
|
|
|
370
384
|
string xhsId = configModel.xhs != null ? configModel.xhs.app_id_ios : null;
|
|
371
385
|
string douyinId = configModel.douyin != null ? configModel.douyin.app_id : null;
|
|
372
|
-
|
|
386
|
+
string tiktokId = configModel.tiktok != null ? configModel.tiktok.client_key : null;
|
|
373
387
|
|
|
374
388
|
// 添加 CFBundleURLTypes,用添加而不是覆盖
|
|
375
389
|
PlistElementDict dict = _plist.root.AsDict();
|
|
@@ -387,6 +401,14 @@ namespace XD.SDK.Common.Editor
|
|
|
387
401
|
{
|
|
388
402
|
array = dict.CreateArray("CFBundleURLTypes");
|
|
389
403
|
}
|
|
404
|
+
|
|
405
|
+
if (xdClientId != null)
|
|
406
|
+
{
|
|
407
|
+
PlistElementDict dictInner = array.AddDict();
|
|
408
|
+
dictInner.SetString("CFBundleURLName", "XD");
|
|
409
|
+
PlistElementArray array2 = dictInner.CreateArray("CFBundleURLSchemes");
|
|
410
|
+
array2.AddString($"xd{xdClientId}");
|
|
411
|
+
}
|
|
390
412
|
|
|
391
413
|
// 添加 FacebookAppID 和 FacebookClientToken
|
|
392
414
|
if (facebookId != null && facebookToken != null)
|
|
@@ -485,6 +507,15 @@ namespace XD.SDK.Common.Editor
|
|
|
485
507
|
array2 = dict2.CreateArray("CFBundleURLSchemes");
|
|
486
508
|
array2.AddString(douyinId);
|
|
487
509
|
}
|
|
510
|
+
|
|
511
|
+
if (!string.IsNullOrEmpty(tiktokId))
|
|
512
|
+
{
|
|
513
|
+
dict2 = array.AddDict();
|
|
514
|
+
dict2.SetString("CFBundleURLName", "tiktok");
|
|
515
|
+
PlistElementArray array2 = dict2.CreateArray("CFBundleURLSchemes");
|
|
516
|
+
array2 = dict2.CreateArray("CFBundleURLSchemes");
|
|
517
|
+
array2.AddString(tiktokId);
|
|
518
|
+
}
|
|
488
519
|
|
|
489
520
|
File.WriteAllText(_plistPath, _plist.WriteToString());
|
|
490
521
|
}
|
|
@@ -529,14 +560,16 @@ namespace XD.SDK.Common.Editor
|
|
|
529
560
|
UnityAppController.WriteBelow(@"#include <assert.h>", @"#import <XDCommonSDK/XDCommonSDK.h>");
|
|
530
561
|
|
|
531
562
|
UnityAppController.WriteBelow(@"applicationDidFinishLaunching",
|
|
532
|
-
@"[XDGSDK application:application didFinishLaunchingWithOptions:launchOptions];");
|
|
563
|
+
@" [XDGSDK application:application didFinishLaunchingWithOptions:launchOptions];");
|
|
533
564
|
UnityAppController.WriteBelow(@"AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);",
|
|
534
|
-
@"[XDGSDK application:app openURL:url options:options];");
|
|
565
|
+
@" [XDGSDK application:app openURL:url options:options];");
|
|
566
|
+
UnityAppController.WriteBelow(@"AppController_SendNotificationWithArg(kUnityDidRegisterForRemoteNotificationsWithDeviceToken, deviceToken);", @" [XDGSDK application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];");
|
|
567
|
+
UnityAppController.WriteBetween(@"UnitySendRemoteNotification(userInfo);", @"if (handler)", @" [XDGSDK application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:NULL];");
|
|
535
568
|
|
|
536
569
|
if (CheckoutUniversalLinkHolder(unityAppControllerPath, @"NSURL* url = userActivity.webpageURL;"))
|
|
537
570
|
{
|
|
538
571
|
UnityAppController.WriteBelow(@"NSURL* url = userActivity.webpageURL;",
|
|
539
|
-
@"[XDGSDK application:application continueUserActivity:userActivity restorationHandler:restorationHandler];");
|
|
572
|
+
@" [XDGSDK application:application continueUserActivity:userActivity restorationHandler:restorationHandler];");
|
|
540
573
|
}
|
|
541
574
|
else
|
|
542
575
|
{
|