update: 更新 IsIAPUser 标志位
parent
8e2b78a385
commit
6a59816453
|
|
@ -57,7 +57,7 @@ namespace Guru
|
|||
/// <summary>
|
||||
/// 恢复购买回调
|
||||
/// </summary>
|
||||
public event Action<bool> OnRestored;
|
||||
public event Action<bool, string> OnRestored;
|
||||
|
||||
public event Action<string> OnBuyStart;
|
||||
public event Action<string, bool> OnBuyEnd;
|
||||
|
|
@ -130,9 +130,6 @@ namespace Guru
|
|||
Initialize(showLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化支付插件
|
||||
/// </summary>
|
||||
|
|
@ -425,10 +422,28 @@ namespace Guru
|
|||
/// 恢复购买
|
||||
/// </summary>
|
||||
/// <param name="success"></param>
|
||||
protected virtual void OnRestoreHandle(bool success)
|
||||
/// <param name="msg"></param>
|
||||
protected virtual void OnRestoreHandle(bool success, string msg)
|
||||
{
|
||||
LogI($"--- Restore complete: {success}" );
|
||||
OnRestored?.Invoke(success);
|
||||
LogI($"--- Restore complete: {success}: msg:{msg}" );
|
||||
|
||||
|
||||
if (success)
|
||||
{
|
||||
bool isIAPUser = false;
|
||||
// 扫描所有商品, 追加用户属性
|
||||
for (int i = 0; i < _storeController.products.all.Length; i++)
|
||||
{
|
||||
var product = _storeController.products.all[i];
|
||||
if (product.hasReceipt)
|
||||
{
|
||||
isIAPUser = true;
|
||||
}
|
||||
}
|
||||
SetIsIAPUser(isIAPUser);
|
||||
}
|
||||
|
||||
OnRestored?.Invoke(success, msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -444,6 +459,7 @@ namespace Guru
|
|||
_googlePlayStoreExtensions.RestoreTransactions(OnRestoreHandle);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -513,6 +529,8 @@ namespace Guru
|
|||
Analytics.ProductIAP(info.Id,info.Id, info.Price, info.CurrencyCode);
|
||||
Analytics.IAPRetTrue(info.Category, info.Id, info.Price, info.CurrencyCode, info.Type, info.IsFree);
|
||||
success = true;
|
||||
|
||||
SetIsIAPUser(success); // 设置用户属性标记
|
||||
}
|
||||
|
||||
PurchaseCount++; // 记录支付次数
|
||||
|
|
@ -749,6 +767,19 @@ namespace Guru
|
|||
|
||||
#endregion
|
||||
|
||||
#region 用户标志位设置
|
||||
|
||||
/// <summary>
|
||||
/// 标记是否为付费用户
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public static void SetIsIAPUser(bool value = true)
|
||||
{
|
||||
Analytics.SetUserProperty(Analytics.PropertyIsIAPUser, value ? "true" : "false");
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue