61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
#if UNITY_WEBGL && WEBGL_WX
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using JetBrains.Annotations;
|
|
using WeChatWASM;
|
|
|
|
namespace HC
|
|
{
|
|
public class HCWXShare : HCIShare
|
|
{
|
|
public HCWXShare()
|
|
{
|
|
HCAnalyticsManager.Instance.RemoteConfigListen += RemoteConfigUpdate;
|
|
OnListenShare();
|
|
}
|
|
|
|
private static void OnListenShare()
|
|
{
|
|
var shareImageUrl = HCAnalyticsManager.Instance.GetRemoteConfigStr("share_imageUrl", "");
|
|
var shareTitle = HCAnalyticsManager.Instance.GetRemoteConfigStr("share_title", "");
|
|
HCDebugger.LogDebug($"[HCWXShare] [OnListenShare] start");
|
|
WX.OnShareTimeline(action =>
|
|
{
|
|
HCDebugger.LogDebug($"[HCWXShare] [OnListenShare] action = {action}");
|
|
HCDebugger.LogDebug($"[HCWXShare] [OnListenShare] action = {action} shareImageUrl = {shareImageUrl} shareTitle = {shareTitle}");
|
|
action.Invoke(new OnShareTimelineListenerResult
|
|
{
|
|
imageUrl = shareImageUrl,
|
|
title = shareTitle
|
|
});
|
|
});
|
|
WXBase.OnShareAppMessage(new WXShareAppMessageParam
|
|
{
|
|
imageUrl = shareImageUrl,
|
|
title = shareTitle
|
|
});
|
|
}
|
|
|
|
public void Share(string title, string imgUrl, string content, Action<bool> callback, int type = 0)
|
|
{
|
|
var shareAppMessageOption = new ShareAppMessageOption
|
|
{
|
|
title = title
|
|
};
|
|
|
|
if (!string.IsNullOrEmpty(imgUrl))
|
|
{
|
|
shareAppMessageOption.imageUrl = imgUrl;
|
|
}
|
|
|
|
WX.ShareAppMessage(shareAppMessageOption);
|
|
callback?.Invoke(true);
|
|
}
|
|
|
|
private static void RemoteConfigUpdate(TrackEventPlatform platform, Dictionary<string, object> config)
|
|
{
|
|
OnListenShare();
|
|
}
|
|
}
|
|
}
|
|
#endif |