diff --git a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs index 32909b4..45b0ce9 100644 --- a/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs +++ b/Runtime/GuruIAP/Runtime/Code/IAPServiceBase.cs @@ -22,7 +22,6 @@ namespace Guru private const string DefaultCategory = "Store"; private static bool _showLog; - private static string _uuid; private ConfigurationBuilder _configBuilder; // 商店配置创建器 @@ -70,6 +69,7 @@ namespace Guru private byte[] _googlePublicKey; private byte[] _appleRootCert; + private string _uid; /// /// 服务初始化回调 @@ -133,9 +133,11 @@ namespace Guru /// /// 初始化支付服务 /// - public virtual void Initialize(string uuid, bool showLog = false) + public virtual void Initialize(string uid, bool showLog = false) { - _uuid = uuid; + + if (string.IsNullOrEmpty(uid)) uid = IPMConfig.IPM_UID; + _uid = uid; _showLog = showLog; InitPurchasing(); } @@ -147,12 +149,12 @@ namespace Guru /// /// /// - public virtual void InitWithKeys(string uuid, byte[] googlePublicKey, byte[] appleRootCert, bool showLog = false) + public virtual void InitWithKeys(string uid, byte[] googlePublicKey, byte[] appleRootCert, bool showLog = false) { _googlePublicKey = googlePublicKey; _appleRootCert = appleRootCert; InitModel(); - Initialize(uuid, showLog); + Initialize(uid, showLog); } /// @@ -229,13 +231,14 @@ namespace Guru { _storeController = controller; _storeExtensionProvider = extensions; - if (string.IsNullOrEmpty(_uuid)) _uuid = IPMConfig.IPM_DEVICE_ID; - - LogI($"--- IAP Initialized Success. With UID: {_uuid}"); + var uuid = IPMConfig.IPM_DEVICE_ID; + if(string.IsNullOrEmpty(_uid)) _uid = IPMConfig.IPM_UID; + + LogI($"--- IAP Initialized Success. With UID: {_uid} and UUID: {uuid}"); #if UNITY_IOS _appleExtensions = extensions.GetExtension(); - _appleExtensions.SetApplicationUsername(_uuid); // SetUp UID + _appleExtensions.SetApplicationUsername(uuid); // SetUp UUID (8)-(4)-(4)-(12): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. _appleExtensions.RegisterPurchaseDeferredListener(item => @@ -244,7 +247,7 @@ namespace Guru OnAppStorePurchaseDeferred?.Invoke(item); }); #elif UNITY_ANDROID - _configBuilder.Configure().SetObfuscatedAccountId(_uuid); // SetUp UID + _configBuilder.Configure().SetObfuscatedAccountId(_uid); // SetUp UID _googlePlayStoreExtensions = extensions.GetExtension(); //添加安装游戏后第一次初试化进行恢复购买的回调 只有安卓才有 _googlePlayStoreExtensions.RestoreTransactions(OnRestoreHandle);