update: 更新 IsIAPUser 标志位
							parent
							
								
									8e2b78a385
								
							
						
					
					
						commit
						6a59816453
					
				| 
						 | 
					@ -57,7 +57,7 @@ namespace Guru
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 恢复购买回调
 | 
					        /// 恢复购买回调
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public event Action<bool> OnRestored;
 | 
					        public event Action<bool, string> OnRestored;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public event Action<string> OnBuyStart;
 | 
					        public event Action<string> OnBuyStart;
 | 
				
			||||||
        public event Action<string, bool> OnBuyEnd;
 | 
					        public event Action<string, bool> OnBuyEnd;
 | 
				
			||||||
| 
						 | 
					@ -130,9 +130,6 @@ namespace Guru
 | 
				
			||||||
            Initialize(showLog);
 | 
					            Initialize(showLog);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 初始化支付插件
 | 
					        /// 初始化支付插件
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
| 
						 | 
					@ -425,10 +422,28 @@ namespace Guru
 | 
				
			||||||
        /// 恢复购买
 | 
					        /// 恢复购买
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="success"></param>
 | 
					        /// <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}" );
 | 
					            LogI($"--- Restore complete: {success}: msg:{msg}" );
 | 
				
			||||||
            OnRestored?.Invoke(success);
 | 
					
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            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>
 | 
					        /// <summary>
 | 
				
			||||||
| 
						 | 
					@ -445,6 +460,7 @@ namespace Guru
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #region 购买流程
 | 
					        #region 购买流程
 | 
				
			||||||
| 
						 | 
					@ -513,6 +529,8 @@ namespace Guru
 | 
				
			||||||
                Analytics.ProductIAP(info.Id,info.Id, info.Price, info.CurrencyCode);
 | 
					                Analytics.ProductIAP(info.Id,info.Id, info.Price, info.CurrencyCode);
 | 
				
			||||||
                Analytics.IAPRetTrue(info.Category, info.Id, info.Price, info.CurrencyCode, info.Type, info.IsFree);
 | 
					                Analytics.IAPRetTrue(info.Category, info.Id, info.Price, info.CurrencyCode, info.Type, info.IsFree);
 | 
				
			||||||
                success = true;
 | 
					                success = true;
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                SetIsIAPUser(success); // 设置用户属性标记
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            PurchaseCount++; // 记录支付次数
 | 
					            PurchaseCount++; // 记录支付次数
 | 
				
			||||||
| 
						 | 
					@ -749,6 +767,19 @@ namespace Guru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #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