添加ios渠道的aihelper

main
zhangaotian 2026-04-02 15:40:42 +08:00
parent e93ba3c245
commit a2747bfe03
198 changed files with 9038 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<dependencies>
<androidPackages>
<androidPackage spec="net.aihelp:android-aihelp-aar:5.6.+">
<repositories>
<repository>https://mvn.aihelp.net/repository/maven-public/</repository>
</repositories>
</androidPackage>
</androidPackages>
</dependencies>

View File

@ -0,0 +1,115 @@
using System;
namespace AIHelp
{
public class AIHelpSupport
{
public static void Initialize(string domain, string appId, string language)
{
AIHelpCore.getInstance().Initialize(domain, appId, language);
}
public static void Initialize(string domain, string appId)
{
Initialize(domain, appId, "");
}
public static void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
{
AIHelpCore.getInstance().RegisterAsyncEventListener(eventType, listener);
}
public static void UnregisterAsyncEventListener(AIHelp.EventType eventType)
{
AIHelpCore.getInstance().UnregisterAsyncEventListener(eventType);
}
public static bool Show(string entranceId)
{
return AIHelpCore.getInstance().Show(entranceId);
}
public static bool Show(ApiConfig apiConfig)
{
return AIHelpCore.getInstance().Show(apiConfig);
}
public static void ShowSingleFAQ(string faqId, ConversationMoment moment)
{
AIHelpCore.getInstance().ShowSingleFAQ(faqId, moment);
}
public static void Login(string userId)
{
Login(new LoginConfig.Builder().SetUserId(userId).Build());
}
public static void Login(LoginConfig loginConfig)
{
AIHelpCore.getInstance().Login(loginConfig);
}
public static void UpdateUserInfo(UserConfig userConfig)
{
AIHelpCore.getInstance().UpdateUserInfo(userConfig);
}
public static void ResetUserInfo()
{
AIHelpCore.getInstance().ResetUserInfo();
}
public static void UpdateSDKLanguage(string language)
{
AIHelpCore.getInstance().UpdateSDKLanguage(language);
}
public static void SetUploadLogPath(string path)
{
AIHelpCore.getInstance().SetUploadLogPath(path);
}
public static void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
{
AIHelpCore.getInstance().SetPushTokenAndPlatform(pushToken, platform);
}
public static void FetchUnreadMessageCount()
{
AIHelpCore.getInstance().FetchUnreadMessageCount();
}
public static void FetchUnreadTaskCount()
{
AIHelpCore.getInstance().FetchUnreadTaskCount();
}
public static string GetSDKVersion()
{
return AIHelpCore.getInstance().GetSDKVersion();
}
public static bool IsAIHelpShowing()
{
return AIHelpCore.getInstance().IsAIHelpShowing();
}
public static void enableLogging(bool enable)
{
AIHelpCore.getInstance().EnableLogging(enable);
}
public static void ShowUrl(string url)
{
AIHelpCore.getInstance().ShowUrl(url);
}
public static void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
{
AIHelpCore.getInstance().AdditionalSupportFor(countryOrRegion);
}
public static void Close() {
AIHelpCore.getInstance().Close();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef1e7be80affb4af588e5c113403b225
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,82 @@
#if SDK_AIHELPER
using AIHelp;
using UnityEngine;
namespace PhxhSDK
{
public partial class AIhelperSdkHelper : SdkHelper
{
#region SDK接入信息
private const string APP_DOMAIN = "naluoda.aihelpcn.net";
#if UNITY_IOS
private const string APP_ID = "naluoda_platform_7fae5e44ad31066aa157d251ffb162ca";
#elif UNITY_ANDROID
private const string APP_ID = "naluoda_platform_3f285c0fedc219ea176f6198642e622b";
#else
private const string APP_ID = "naluoda_platform_84fa488485b5c8dd7ea905c92941ace0";
#endif
private const bool USER_FROM_MAINLAND_CHINA = true;
#endregion
public override void AfterLoginInit()
{
}
public override void EarlyInit()
{
try
{
if (USER_FROM_MAINLAND_CHINA)
{
AIHelpSupport.AdditionalSupportFor(PublishCountryOrRegion.CN);
}
AIHelpSupport.Initialize(
APP_DOMAIN,
APP_ID
);
AIHelpSupport.RegisterAsyncEventListener(
AIHelp.EventType.Initialization,
(jsonData, ack) =>
{
// When init job is done, you can get callback here
// `jsonData`: { "isSuccess": true, "message": "Success" }
DebugUtil.Log("AIHelp SDK 初始化完成: {0}", jsonData);
}
);
}
catch
{
DebugUtil.Log("AIHelp 初始化失败");
}
}
public override void Init()
{
}
public override void Release()
{
}
public override void Update()
{
}
public void AIhelpEntrance(string enterID = "E001")
{
AIHelpSupport.Show(enterID);
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: caffe315b5072044baf72511877bd827
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2849caac28eb049d1aeabcee4d7abe31
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using System;
namespace AIHelp
{
public class ApiConfig
{
public string EntranceId { get; }
public string WelcomeMessage { get; }
private ApiConfig(Builder builder)
{
EntranceId = builder.EntranceId;
WelcomeMessage = builder.WelcomeMessage;
}
public class Builder
{
public string EntranceId { get; private set; }
public string WelcomeMessage { get; private set; }
public Builder SetEntranceId(string entranceId)
{
EntranceId = entranceId;
return this;
}
public Builder SetWelcomeMessage(string welcomeMessage)
{
WelcomeMessage = welcomeMessage;
return this;
}
public ApiConfig Build()
{
return new ApiConfig(this);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af06fba061d114dee8bab53d2386c967
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
using System;
namespace AIHelp
{
public class AIHelpDelegate
{
public delegate void AsyncEventListener(String jsonEventData, Action<string> acknowledge);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 667f6671ba9b540dba0f6c7aedc71883
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,70 @@
using System;
namespace AIHelp
{
public enum PushPlatform
{
APNS = 1, FIREBASE = 2, JIGUANG = 3, GETUI = 4, HUAWEI = 6, ONE_SIGNAL = 7
}
public enum ConversationMoment
{
NEVER = 1, ALWAYS = 2, ONLY_IN_ANSWER_PAGE = 3, AFTER_MARKING_UNHELPFUL = 4
}
public enum PublishCountryOrRegion
{
CN = 1, IN = 2
};
public enum EventType
{
/**
* Event for SDK initialization
*/
Initialization,
/**
* Event for user login
*/
UserLogin,
/**
* Event for enterprise authentication
*/
EnterpriseAuth,
/**
* Event for opening or closing a session (window)
*/
SessionOpen,
SessionClose,
/**
* Event for message arrival
*/
MessageArrival,
/**
* Event for log upload
*/
LogUpload,
/**
* Event for URL click
*/
UrlClick,
/**
* Event for unread task count
*/
UnreadTaskCount,
/**
* Event for conversation start, along with the user's first message
*/
ConversationStart,
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9fbae61ea0fb14752bcd772995401549
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using System;
namespace AIHelp
{
public class LoginConfig
{
public string UserId { get; }
public UserConfig UserConfig { get; }
private LoginConfig(Builder builder)
{
UserId = builder.UserId;
UserConfig = builder.UserConfig;
}
public class Builder
{
public string UserId { get; private set; }
public UserConfig UserConfig { get; private set; }
public Builder SetUserId(string userId)
{
UserId = userId;
return this;
}
public Builder SetUserConfig(UserConfig userConfig)
{
UserConfig = userConfig;
return this;
}
public LoginConfig Build()
{
return new LoginConfig(this);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 53e798a014f114fdf8e104f67b645563
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using System;
namespace AIHelp
{
public class UserConfig
{
public string UserName { get; }
public string ServerId { get; }
public string UserTags { get; }
public string CustomData { get; }
private UserConfig(Builder builder)
{
UserName = builder.UserName;
ServerId = builder.ServerId;
UserTags = builder.UserTags;
CustomData = builder.CustomData;
}
public class Builder
{
public string UserName { get; private set; } = "anonymous";
public string ServerId { get; private set; } = "-1";
public string UserTags { get; private set; } = string.Empty;
public string CustomData { get; private set; } = string.Empty;
public Builder SetUserName(string userName)
{
UserName = userName;
return this;
}
public Builder SetServerId(string serverId)
{
ServerId = serverId;
return this;
}
public Builder SetUserTags(string userTags)
{
UserTags = userTags;
return this;
}
public Builder SetCustomData(string customDataJsonstring)
{
CustomData = customDataJsonstring;
return this;
}
public UserConfig Build()
{
return new UserConfig(this);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e8a896a44c3dd450a881ddd9cc5ba37e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d75f665a144f143bebb1e0d2bd5d3266
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,232 @@
using UnityEngine;
using System;
namespace AIHelp
{
#if UNITY_ANDROID
public class AIHelpAndroidCore : IAIHelpCore
{
private AndroidJavaClass javaSupport;
private AndroidJavaObject currentActivity;
public AIHelpAndroidCore()
{
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
javaSupport = new AndroidJavaClass("net.aihelp.init.AIHelpSupport");
currentActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
}
public void Initialize(string domain, string appId, string language)
{
if (javaSupport != null && currentActivity != null)
{
javaSupport.CallStatic("initialize", currentActivity, domain, appId, language);
}
}
private AndroidJavaObject getLoginConfig(LoginConfig config)
{
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.LoginConfig$Builder");
builder.Call<AndroidJavaObject>("setUserId", config.UserId);
builder.Call<AndroidJavaObject>("setUserConfig", getUserConfig(config.UserConfig));
return builder.Call<AndroidJavaObject>("build");
}
private AndroidJavaObject getApiConfig(ApiConfig config)
{
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.ApiConfig$Builder");
return builder.Call<AndroidJavaObject>("build", config.EntranceId, config.WelcomeMessage);
}
private AndroidJavaObject getUserConfig(UserConfig config)
{
if(config == null) return null;
AndroidJavaObject builder = new AndroidJavaObject("net.aihelp.config.UserConfig$Builder");
builder.Call<AndroidJavaObject>("setUserName", config.UserName);
builder.Call<AndroidJavaObject>("setServerId", config.ServerId);
builder.Call<AndroidJavaObject>("setUserTags", config.UserTags);
builder.Call<AndroidJavaObject>("setCustomData", config.CustomData);
return builder.Call<AndroidJavaObject>("build");
}
private AndroidJavaObject getPublishCountryOrRegion(PublishCountryOrRegion countryOrRegion)
{
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.PublishCountryOrRegion");
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)countryOrRegion);
}
private AndroidJavaObject getPushPlatform(PushPlatform platform)
{
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.PushPlatform");
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)platform);
}
private AndroidJavaObject getShowConversationMoment(ConversationMoment conversationMoment)
{
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.config.enums.ShowConversationMoment");
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)conversationMoment);
}
private AndroidJavaObject getEventType(EventType eventType)
{
AndroidJavaClass clz = new AndroidJavaClass("net.aihelp.event.EventType");
return clz.CallStatic<AndroidJavaObject>("fromValue", (int)eventType);
}
public bool Show(string entranceId)
{
if (javaSupport != null && currentActivity != null)
{
return javaSupport.CallStatic<bool>("show", entranceId);
}
return false;
}
public bool Show(ApiConfig apiConfig)
{
if (javaSupport != null && currentActivity != null)
{
return javaSupport.CallStatic<bool>("show", getApiConfig(apiConfig));
}
return false;
}
public void ShowSingleFAQ(string faqId, ConversationMoment conversationMoment)
{
if (javaSupport != null && currentActivity != null)
{
javaSupport.CallStatic("showSingleFAQ", faqId, getShowConversationMoment(conversationMoment));
}
}
public void Login(LoginConfig loginConfig)
{
if (javaSupport != null && currentActivity != null)
{
javaSupport.CallStatic("login", getLoginConfig(loginConfig));
}
}
public void Logout()
{
if (javaSupport != null && currentActivity != null)
{
javaSupport.CallStatic("logout");
}
}
public void UpdateUserInfo(UserConfig config)
{
if (javaSupport != null)
{
javaSupport.CallStatic("updateUserInfo", getUserConfig(config));
}
}
public void ResetUserInfo()
{
if (javaSupport != null)
{
javaSupport.CallStatic("resetUserInfo");
}
}
public void UpdateSDKLanguage(string language)
{
if (javaSupport != null)
{
javaSupport.CallStatic("updateSDKLanguage", language);
}
}
public void SetUploadLogPath(string logPath)
{
if (javaSupport != null)
{
javaSupport.CallStatic("setUploadLogPath", logPath);
}
}
public void SetPushTokenAndPlatform(string logPath, PushPlatform pushPlatform)
{
if (javaSupport != null)
{
javaSupport.CallStatic("setPushTokenAndPlatform", logPath, getPushPlatform(pushPlatform));
}
}
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
{
javaSupport.CallStatic("registerAsyncEventListener", getEventType(eventType), listener == null ? null : new AsyncEventListenerProxy(listener));
}
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
{
javaSupport.CallStatic("unregisterAsyncEventListener", getEventType(eventType));
}
public void FetchUnreadMessageCount()
{
javaSupport.CallStatic("fetchUnreadMessageCount");
}
public void FetchUnreadTaskCount()
{
javaSupport.CallStatic("fetchUnreadTaskCount");
}
public void ShowUrl(string url)
{
if (javaSupport != null)
{
javaSupport.CallStatic("showUrl", url);
}
}
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
{
if (javaSupport != null)
{
javaSupport.CallStatic("additionalSupportFor", getPublishCountryOrRegion(countryOrRegion));
}
}
public string GetSDKVersion()
{
if (javaSupport != null)
{
return javaSupport.CallStatic<string>("getSDKVersion");
}
return "";
}
public bool IsAIHelpShowing()
{
if (javaSupport != null)
{
return javaSupport.CallStatic<bool>("isAIHelpShowing");
}
return false;
}
public void EnableLogging(bool isOpen)
{
if (javaSupport != null)
{
javaSupport.CallStatic("enableLogging", isOpen);
}
}
public void Close()
{
if (javaSupport != null)
{
javaSupport.CallStatic("close");
}
}
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5025625f2980b4854a698e38b5e1478f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,174 @@
using System;
using UnityEngine;
namespace AIHelp
{
public class AIHelpCore
{
private IAIHelpCore helpCore;
private static AIHelpCore sInstance;
private AIHelpCore()
{
#if UNITY_ANDROID
if (Application.platform == RuntimePlatform.Android) {
helpCore = new AIHelpAndroidCore();
}
#endif
#if UNITY_IOS
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
helpCore = new AIHelpiOSCore();
}
#endif
}
public static AIHelpCore getInstance()
{
if (sInstance == null)
{
sInstance = new AIHelpCore();
}
return sInstance;
}
public void Initialize(string domain, string appId, string language)
{
if (!IsHelpCorePrepared()) return;
helpCore.Initialize(domain, appId, language);
}
public void Initialize(string domain, string appId)
{
Initialize(domain, appId, "");
}
public bool Show(string entranceId)
{
if (!IsHelpCorePrepared()) return false;
return helpCore.Show(entranceId);
}
public bool Show(ApiConfig apiConfig)
{
if (!IsHelpCorePrepared()) return false;
return helpCore.Show(apiConfig);
}
public void ShowSingleFAQ(string faqId, ConversationMoment moment)
{
if (!IsHelpCorePrepared()) return;
helpCore.ShowSingleFAQ(faqId, moment);
}
public void Login(LoginConfig loginConfig)
{
if (!IsHelpCorePrepared()) return;
helpCore.Login(loginConfig);
}
public void Logout()
{
if (!IsHelpCorePrepared()) return;
helpCore.Logout();
}
public void UpdateUserInfo(UserConfig userConfig)
{
if (!IsHelpCorePrepared()) return;
helpCore.UpdateUserInfo(userConfig);
}
public void ResetUserInfo()
{
if (!IsHelpCorePrepared()) return;
helpCore.ResetUserInfo();
}
public void UpdateSDKLanguage(string language)
{
if (!IsHelpCorePrepared()) return;
helpCore.UpdateSDKLanguage(language);
}
public void SetUploadLogPath(string path)
{
if (!IsHelpCorePrepared()) return;
helpCore.SetUploadLogPath(path);
}
public void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
{
if (!IsHelpCorePrepared()) return;
helpCore.SetPushTokenAndPlatform(pushToken, platform);
}
public void FetchUnreadMessageCount()
{
if (!IsHelpCorePrepared()) return;
helpCore.FetchUnreadMessageCount();
}
public void FetchUnreadTaskCount()
{
if (!IsHelpCorePrepared()) return;
helpCore.FetchUnreadTaskCount();
}
public string GetSDKVersion()
{
if (!IsHelpCorePrepared()) return "";
return helpCore.GetSDKVersion();
}
public bool IsAIHelpShowing()
{
if (!IsHelpCorePrepared()) return false;
return helpCore.IsAIHelpShowing();
}
public void EnableLogging(bool enable)
{
if (!IsHelpCorePrepared()) return;
helpCore.EnableLogging(enable);
}
public void ShowUrl(string url)
{
if (!IsHelpCorePrepared()) return;
helpCore.ShowUrl(url);
}
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
{
if (!IsHelpCorePrepared()) return;
helpCore.AdditionalSupportFor(countryOrRegion);
}
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
{
if (!IsHelpCorePrepared()) return;
helpCore.RegisterAsyncEventListener(eventType, listener);
}
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
{
if (!IsHelpCorePrepared()) return;
helpCore.UnregisterAsyncEventListener(eventType);
}
public void Close()
{
if (!IsHelpCorePrepared()) return;
helpCore.Close();
}
private bool IsHelpCorePrepared()
{
return helpCore != null;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f9ac1ead074e4a2586b265550d1fae8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,150 @@
// We need this one for importing our IOS functions
using System.Runtime.InteropServices;
using AOT;
using System;
namespace AIHelp
{
#if UNITY_IOS
public partial class AIHelpiOSCore : IAIHelpCore
{
public void Initialize(string domain, string appId, string language = "")
{
unity_initiailize(domain, appId, language);
}
public void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener)
{
eventListeners[eventType] = listener;
unity_registerAsyncEventListener(eventType, OCAsyncEventListener);
}
public void UnregisterAsyncEventListener(AIHelp.EventType eventType)
{
unity_unregisterAsyncEventListener(eventType);
}
public bool Show(string entranceId)
{
return unity_show(entranceId, "");
}
public bool Show(ApiConfig apiConfig)
{
return unity_show(apiConfig.EntranceId, apiConfig.WelcomeMessage);
}
public void ShowSingleFAQ(string faqId, ConversationMoment moment)
{
unity_showSingleFAQ(faqId, (int)moment);
}
public void Login(LoginConfig loginConfig) {
var userConfig = loginConfig.UserConfig;
if (userConfig == null) {
userConfig = new UserConfig.Builder().Build();
}
unity_login(loginConfig.UserId, userConfig.UserName, userConfig.ServerId, userConfig.UserTags, userConfig.CustomData);
}
public void Logout() {
unity_logout();
}
public void UpdateUserInfo(UserConfig userConfig)
{
unity_updateUserInfo(userConfig.UserName, userConfig.ServerId, userConfig.UserTags, userConfig.CustomData);
}
public void ResetUserInfo()
{
unity_resetUserInfo();
}
public void UpdateSDKLanguage(string language)
{
unity_updateSDKLanguage(language);
}
public void SetUploadLogPath(string path)
{
unity_setUploadLogPath(path);
}
public void SetPushTokenAndPlatform(string pushToken, PushPlatform platform)
{
unity_setPushTokenAndPlatform(pushToken, getPushPlatform(platform));
}
public void FetchUnreadMessageCount()
{
unity_fetchUnreadMessageCount();
}
public void FetchUnreadTaskCount()
{
unity_fetchUnreadTaskCount();
}
public string GetSDKVersion()
{
return unity_getSDKVersion();
}
public bool IsAIHelpShowing()
{
return unity_isAIHelpShowing();
}
public void EnableLogging(bool enable)
{
unity_enableLogging(enable);
}
public void ShowUrl(string url)
{
unity_showUrl(url);
}
public void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion)
{
unity_additionalSupportFor(countryOrRegion);
}
public void Close() {
unity_close();
}
private int getPushPlatform(PushPlatform platform){
int tempPlatform = 2;
if (platform == PushPlatform.APNS)
{
tempPlatform = 1;
}
else if (platform == PushPlatform.FIREBASE)
{
tempPlatform = 2;
}
else if (platform == PushPlatform.JIGUANG)
{
tempPlatform = 3;
}
else if (platform == PushPlatform.GETUI)
{
tempPlatform = 4;
}
else if (platform == PushPlatform.HUAWEI)
{
tempPlatform = 6;
}
else if (platform == PushPlatform.ONE_SIGNAL)
{
tempPlatform = 7;
}
return tempPlatform;
}
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2a510a461fd54d4881c024ad42035ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b10e874e5837b4579b62e9924a20f806
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using UnityEngine;
using System;
namespace AIHelp
{
#if UNITY_ANDROID
public class AsyncEventListenerProxy : AndroidJavaProxy
{
private readonly AIHelpDelegate.AsyncEventListener eventListener;
private AndroidJavaObject ackRef;
public AsyncEventListenerProxy(AIHelpDelegate.AsyncEventListener eventListener) : base("net.aihelp.event.AsyncEventListener")
{
this.eventListener = eventListener;
}
void onAsyncEventReceived(string jsonEventData, AndroidJavaObject ack)
{
ackRef = ack;
var jniThread = System.Threading.Thread.CurrentThread;
Action<string> acknowledge = jsonAckData =>
{
bool isAttached = false;
bool isAsync = System.Threading.Thread.CurrentThread != jniThread;
try
{
// Attach the current thread to the JNI environment
if (AndroidJNI.AttachCurrentThread() == (int)IntPtr.Zero)
{
isAttached = true;
}
if (ackRef != null)
{
ackRef.Call("acknowledge", jsonAckData);
}
}
catch (Exception e)
{
// Handle any exceptions that may occur during the JNI call
Debug.LogError("Exception during JNI call: " + e.Message);
}
finally
{
if (isAsync && isAttached)
{
// Ensure we detach the current thread from the JNI environment if it was attached
AndroidJNI.DetachCurrentThread();
}
}
};
eventListener(jsonEventData, acknowledge);
}
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 212c0cec872fc40fca66b6827ac48f80
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,38 @@
using System;
namespace AIHelp
{
public interface IAIHelpCore
{
void Initialize(string domain, string appId, string language);
bool Show(string entranceId);
bool Show(ApiConfig apiConfig);
void ShowSingleFAQ(string faqId, ConversationMoment moment);
void Login(LoginConfig loginConfig);
void Logout();
void UpdateUserInfo(UserConfig userConfig);
void ResetUserInfo();
void UpdateSDKLanguage(string language);
void SetUploadLogPath(string path);
void SetPushTokenAndPlatform(string pushToken, PushPlatform platform);
void FetchUnreadMessageCount();
void FetchUnreadTaskCount();
string GetSDKVersion();
bool IsAIHelpShowing();
void EnableLogging(bool enable);
void ShowUrl(string url);
void AdditionalSupportFor(PublishCountryOrRegion countryOrRegion);
void RegisterAsyncEventListener(AIHelp.EventType eventType, AIHelpDelegate.AsyncEventListener listener);
void UnregisterAsyncEventListener(AIHelp.EventType eventType);
void Close();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b63a845cae20749c1be5d13f2ccd2ede
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 54ad73766cfa345e6a6859b9ade52598
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,71 @@
using System;
using System.Runtime.InteropServices;
using AOT;
namespace AIHelp
{
#if UNITY_IOS
public partial class AIHelpiOSCore
{
[DllImport("__Internal")]
private static extern void unity_initiailize(string domainName, string appId, string language);
[DllImport("__Internal")]
private static extern void unity_registerAsyncEventListener(AIHelp.EventType eventType, AIHelpAsyncEventListener listener);
[DllImport("__Internal")]
private static extern void unity_unregisterAsyncEventListener(AIHelp.EventType eventType);
[DllImport("__Internal")]
private static extern void unity_login(string userId, string userName, string serverId, string userTags, string customData);
[DllImport("__Internal")]
private static extern void unity_logout();
[DllImport("__Internal")]
private static extern void unity_updateUserInfo(string userName, string serverId, string userTags, string customData);
[DllImport("__Internal")]
private static extern void unity_resetUserInfo();
[DllImport("__Internal")]
private static extern void unity_updateSDKLanguage(string language);
[DllImport("__Internal")]
private static extern void unity_setUploadLogPath(string path);
[DllImport("__Internal")]
private static extern void unity_setPushTokenAndPlatform(string pushToken, int pushPlatform);
[DllImport("__Internal")]
private static extern string unity_getSDKVersion();
[DllImport("__Internal")]
private static extern bool unity_isAIHelpShowing();
[DllImport("__Internal")]
private static extern void unity_enableLogging(bool enable);
[DllImport("__Internal")]
private static extern void unity_close();
[DllImport("__Internal")]
private static extern bool unity_show(string entranceId, string welcomeMessage);
[DllImport("__Internal")]
private static extern void unity_showSingleFAQ(string faqId, int conversationMoment);
[DllImport("__Internal")]
private static extern void unity_fetchUnreadMessageCount();
[DllImport("__Internal")]
private static extern void unity_fetchUnreadTaskCount();
[DllImport("__Internal")]
private static extern void unity_showUrl(string url);
[DllImport("__Internal")]
private static extern void unity_additionalSupportFor(PublishCountryOrRegion countryOrRegion);
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35414e6ccf0a84d9bb2566d2180a0a6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,52 @@
using System;
using System.Runtime.InteropServices;
using AOT;
using UnityEngine;
using System.Collections.Generic;
namespace AIHelp
{
#if UNITY_IOS
public partial class AIHelpiOSCore
{
private static Dictionary<AIHelp.EventType, AIHelpDelegate.AsyncEventListener> eventListeners =
new Dictionary<AIHelp.EventType, AIHelpDelegate.AsyncEventListener>();
// 在 cs 注册的回调方法
static event AIHelpDelegate.AsyncEventListener csAsyncEventListener;
// oc 传过来的 ack 回调,缓存下来异步使用
public static Acknowledgement AckDelegate { get; set; }
// 声明一个符合 ack 回调的代理,用来持有 ack 回调指针的时候使用
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void Acknowledgement(string ackJsonData);
// OC 回调方法签名 - event, ack
public delegate void AIHelpAsyncEventListener(string jsonEventData, IntPtr acknowledgePtr);
[MonoPInvokeCallback(typeof(AIHelpAsyncEventListener))]
private static void OCAsyncEventListener(string jsonEventData, IntPtr acknowledgePtr)
{
var intEventType = SimpleJsonParser.ExtractEventTypeFromJson(jsonEventData);
if (intEventType != -1) {
AIHelp.EventType eventType = (AIHelp.EventType)SimpleJsonParser.ExtractEventTypeFromJson(jsonEventData);
if (eventListeners.TryGetValue(eventType, out var listener))
{
Action<string> acknowledge = jsonAckData => {
if (acknowledgePtr != IntPtr.Zero) {
AckDelegate = Marshal.GetDelegateForFunctionPointer<Acknowledgement>(acknowledgePtr);
AckDelegate?.Invoke(jsonAckData);
}
};
listener?.Invoke(jsonEventData, acknowledge);
} else {
Debug.LogError($"[AIHelp] Unable to find any listener for event type: {eventType}. Have you declared it?");
}
} else {
Debug.LogError($"[AIHelp] Unable to retrieve eventType from eventData: {jsonEventData}");
}
}
}
#endif
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07b537e2737b74ea38fb190ca953a218
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
using System;
public static class SimpleJsonParser
{
public static int ExtractEventTypeFromJson(string json)
{
string fieldValue = ExtractFieldFromJson(json, "eventType");
if (string.IsNullOrEmpty(fieldValue))
{
return -1;
}
return int.Parse(fieldValue);
}
public static string ExtractFieldFromJson(string json, string fieldName)
{
string target = $"\"{fieldName}\":";
int startIndex = json.IndexOf(target, StringComparison.OrdinalIgnoreCase);
if (startIndex >= 0)
{
startIndex += target.Length;
// Skip whitespace
while (char.IsWhiteSpace(json[startIndex])) startIndex++;
// Determine if the value is a string or number
if (json[startIndex] == '"') // string value
{
startIndex++;
int endIndex = json.IndexOf('"', startIndex);
if (endIndex > startIndex)
{
return json.Substring(startIndex, endIndex - startIndex);
}
}
else // numeric value
{
int endIndex = json.IndexOfAny(new[] { ',', '}', ' ' }, startIndex);
if (endIndex > startIndex)
{
return json.Substring(startIndex, endIndex - startIndex).Trim();
}
}
}
return "";
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb9be6b068ec448f48556f9a85df870c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
// If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:4.0.1'
**BUILD_SCRIPT_DEPS**
}
}
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1442d864b79eb2e4187598c1f275b2e6
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
org.gradle.jvmargs=-Xmx4096m
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
android.enableD8=true

View File

@ -0,0 +1,5 @@
org.gradle.jvmargs=-Xmx4096m
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
android.enableD8=true

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 927914632e987b64fba641b4e8ddba4b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7309fe81dae31e949a2a3ea0533fdd67
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'net.aihelp:android-aihelp-aar:5.7.+'
**DEPS**}
android {
namespace "com.unity3d.player"
ndkPath "**NDKPATH**"
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

View File

@ -0,0 +1,42 @@
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'net.aihelp:android-aihelp-aar:5.7.+'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3b8f94809435142f89e9fd25ab48289b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 79c0a192629934d51b70000e6f664991
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
using System.IO;
using UnityEditor.Android;
using UnityEngine;
// This processor is only used to enable `android.useAndroidX` and `android.enableJetifier` in `gradle.properties` file.
// If you've configure that via other ways, you can just leave this alone.
public class AIHelpPostBuildProcessor : IPostGenerateGradleAndroidProject
{
public int callbackOrder
{
get { return 999; }
}
public void OnPostGenerateGradleAndroidProject(string path)
{
string gradlePropertiesFile = path + "/gradle.properties";
if (File.Exists(gradlePropertiesFile))
{
File.Delete(gradlePropertiesFile);
}
StreamWriter writer = File.CreateText(gradlePropertiesFile);
writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
writer.WriteLine("android.useAndroidX=true");
writer.WriteLine("android.enableJetifier=true");
writer.Flush();
writer.Close();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f1c0914a74834ca1acb257d0b85432f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 86026fd43561442a3a4247d76d2bec38
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28f954260a8a24e4bb26b78941da81db
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,80 @@
fileFormatVersion: 2
guid: 34c46cf5a81094a739a70168c76b0daa
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 1
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude Win: 1
Exclude Win64: 1
Exclude iOS: 0
- first:
Android: Android
second:
enabled: 0
settings:
CPU: ARMv7
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: x86_64
- first:
iPhone: iOS
second:
enabled: 1
settings:
AddToEmbeddedBinaries: false
CPU: AnyCPU
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More