update: 添加Restore 回调

feature/item_system
胡宇飞 2024-01-23 13:57:09 +08:00
parent 09cf293d2e
commit 0bcda4f915
2 changed files with 12 additions and 12 deletions

View File

@ -114,13 +114,6 @@ namespace Guru
/// </summary> /// </summary>
public static class Remote public static class Remote
{ {
internal static Action _onRemoteInitComplete;
public static event Action OnRemoteInitComplete
{
add => _onRemoteInitComplete += value;
remove => _onRemoteInitComplete -= value;
}
internal static Action<bool> _onRemoteFetchComplete; internal static Action<bool> _onRemoteFetchComplete;
public static event Action<bool> OnRemoteFetchComplete public static event Action<bool> OnRemoteFetchComplete
{ {
@ -155,6 +148,14 @@ namespace Guru
remove => _onPurchaseFailed -= value; remove => _onPurchaseFailed -= value;
} }
internal static Action<bool, string> _onIAPRestored;
public static event Action<bool, string> OnIAPRestored
{
add => _onIAPRestored += value;
remove => _onIAPRestored -= value;
}
} }
} }

View File

@ -162,22 +162,21 @@ namespace Guru
#region Restore Purchase #region Restore Purchase
private static Action<bool> _onRestored;
/// <summary> /// <summary>
/// 恢复购买 /// 恢复购买
/// </summary> /// </summary>
/// <param name="restoreCallback"></param> /// <param name="restoreCallback"></param>
public static void Restore(Action<bool> restoreCallback) public static void Restore(Action<bool, string> restoreCallback = null)
{ {
if( restoreCallback != null) Callbacks.IAP.OnIAPRestored += restoreCallback;
if (CheckIAPReady()) if (CheckIAPReady())
{ {
_onRestored = restoreCallback;
GuruIAP.Instance.Restore(); GuruIAP.Instance.Restore();
} }
} }
private static void OnRestored(bool success) private static void OnRestored(bool success, string msg)
{ {
_onRestored?.Invoke(success); Callbacks.IAP._onIAPRestored?.Invoke(success, msg); // 更新回复购买回调
} }
#endregion #endregion