TapDB.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #import <Foundation/Foundation.h>
  2. NS_ASSUME_NONNULL_BEGIN
  3. typedef struct LoginType{
  4. NSString *loginType;
  5. }TapDBLoginType;
  6. /*
  7. 自定义登录方式:
  8. TapDBLoginType customLoginType = {@"custom"};
  9. */
  10. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeTapTap;
  11. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeWeiXin;
  12. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeQQ;
  13. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeTourist;
  14. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeApple;
  15. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeZhifubao;
  16. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeFacebook;
  17. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeGoogle;
  18. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypeTwitter;
  19. FOUNDATION_EXPORT TapDBLoginType const TapDBLoginTypePhoneNumber;
  20. #define TapDBSDK @"TapDB"
  21. #define TapDBSDK_VERSION_NUMBER @"31000001"
  22. #define TapDBSDK_VERSION @"3.10.0"
  23. //版本号
  24. static NSString *const TAPDB_VERSION = @"3.0.9";
  25. @interface TapDB : NSObject
  26. /**
  27. Controls the access to IDFA
  28. If not explicitly set, the default is NO
  29. */
  30. @property (class, nonatomic, assign, getter=isAdvertiserIDCollectionEnabled) BOOL advertiserIDCollectionEnabled;
  31. /**
  32. * 是否打开日志输出
  33. * enbale : YES 打开 NO 关闭
  34. */
  35. + (void)enableLog:(BOOL)enable;
  36. /**
  37. * 调用该接口修改数据发送的域名,有特殊需要时调用,调用必须位于初始化之前
  38. * 域名必须是https://abc.example.com/的格式,不能为空
  39. */
  40. + (void)setHost:(NSString *)host;
  41. /**
  42. * 调用该接口修改自定义事件数据发送的域名,有特殊需要时调用,调用必须位于初始化之前
  43. * 域名必须是https://abc.example.com/的格式,不能为空
  44. */
  45. + (void)setCustomEventHost:(NSString *)host;
  46. + (void)onStart:(NSString *)appId channel:(nullable NSString *)channel version:(nullable NSString *)gameVersion;
  47. /**
  48. * 初始化,尽早调用
  49. * appId: 注册游戏时获得的APP ID
  50. * channel: 分包渠道名称,可为空
  51. * gameVersion: 游戏版本,可为空,为空时,自动获取游戏安装包的版本(Xcode配置中的Version)
  52. * properties: 自定义属性
  53. */
  54. + (void)onStart:(NSString *)appId channel:(nullable NSString *)channel version:(nullable NSString *)gameVersion properties:(nullable NSDictionary *)properties;
  55. + (void)onStartWithClientId:(NSString *)clientId channel:(nullable NSString *)channel version:(nullable NSString *)gameVersion;
  56. //sm
  57. + (void)onStartWithClientId:(NSString *)clientId channel:(nullable NSString *)channel version:(nullable NSString *)gameVersion isCN:(BOOL)isCN;
  58. /**
  59. * 初始化,尽早调用
  60. * clientId: TapTap登录sdk后台页面 client id
  61. * channel: 分包渠道名称,可为空
  62. * gameVersion: 游戏版本,可为空,为空时,自动获取游戏安装包的版本(Xcode配置中的Version)
  63. * properties: 自定义属性
  64. */
  65. + (void)onStartWithClientId:(NSString *)clientId channel:(nullable NSString *)channel version:(nullable NSString *)gameVersion properties:(nullable NSDictionary *)properties;
  66. + (void)setUser:(NSString *)userId;
  67. + (void)setUser:(NSString *)userId properties:(nullable NSDictionary *)properties;
  68. /// 对外隐藏接口
  69. + (void)setUser:(NSString *)userId loginType:(TapDBLoginType)loginType;
  70. /// 记录一个用户(不是游戏角色!!!!),需要保证唯一性
  71. /// @param userId 用户ID。不同用户需要保证ID的唯一性
  72. /// @param loginType 登录方式
  73. /// @param properties 自定义属性
  74. + (void)setUser:(NSString *)userId loginType:(TapDBLoginType)loginType properties:(nullable NSDictionary *)properties;
  75. /**
  76. 登出清理用户
  77. */
  78. + (void)clearUser;
  79. /**
  80. * 目前TapDB SDK仅支持单实例模式,如果多次调用onStart方法,只有最初传入的appid生效。调用该函数可以获取生效的信息
  81. * 返回值:包含appId和channel的NSDictionary,对应的value均可能为nil
  82. */
  83. + (NSDictionary *)getStartInfo;
  84. /// 获取当前的设备标识
  85. + (NSString *)getDeviceId;
  86. /**
  87. * 设置用户等级,初次设置时或升级时调用
  88. * level: 等级
  89. */
  90. + (void)setLevel:(NSInteger)level;
  91. /**
  92. * 设置用户服务器,初次设置或更改服务器的时候调用
  93. * server: 服务器
  94. */
  95. + (void)setServer:(NSString *)server;
  96. /// 设置用户名
  97. /// @param name 必传,长度大于0并小于等于256,用户名
  98. + (void)setName:(NSString *)name;
  99. + (void)onChargeSuccess:(nullable NSString *)orderId product:(nullable NSString *)product amount:(NSInteger)amount currencyType:(nullable NSString *)currencyType payment:(nullable NSString *)payment;
  100. /**
  101. * 充值成功时调用
  102. * orderId: 订单ID,可为空
  103. * product: 产品名称,可为空
  104. * amount: 充值金额(单位分,即无论什么币种,都需要乘以100)
  105. * currencyType: 货币类型,可为空,参考:人民币 CNY,美元 USD;欧元 EUR
  106. * payment: 支付方式,可为空,如:支付宝
  107. * properties: 事件属性,需要在控制后台预先进行配置,值为长度大于0并小于等于256的字符串或绝对值小于1E11的浮点数
  108. */
  109. + (void)onChargeSuccess:(nullable NSString *)orderId product:(nullable NSString *)product amount:(NSInteger)amount currencyType:(nullable NSString *)currencyType payment:(nullable NSString *)payment properties:(nullable NSDictionary *)properties;
  110. /**
  111. * 自定义事件
  112. * eventName: 事件代码,需要在控制后台预先进行配置
  113. * properties: 事件属性,需要在控制后台预先进行配置,值为长度大于0并小于等于256的字符串或绝对值小于1E11的浮点数
  114. */
  115. + (void)trackEvent:(NSString *)eventName properties:(NSDictionary *)properties;
  116. /**
  117. * 自定义事件,即将弃用,请使用trackEvent接口
  118. * eventCode: 事件代码,需要在控制后台预先进行配置
  119. * properties: 事件属性,需要在控制后台预先进行配置,值为长度大于0并小于等于256的字符串或绝对值小于1E11的浮点数
  120. */
  121. + (void)onEvent:(NSString *)eventCode properties:(NSDictionary *)properties DEPRECATED_MSG_ATTRIBUTE("已弃用,请按文档迁移到trackEvent接口");
  122. #pragma mark - operation
  123. /// 初始化设备属性操作
  124. /// @param properties 属性字典
  125. + (void)deviceInitialize:(NSDictionary *)properties;
  126. /// 更新设备属性操作
  127. /// @param properties 属性字典
  128. + (void)deviceUpdate:(NSDictionary *)properties;
  129. /// 设备属性增加操作
  130. /// @param properties 属性字典 暂时只支持数字属性
  131. + (void)deviceAdd:(NSDictionary *)properties;
  132. /// 初始化用户属性操作
  133. /// @param properties 属性字典
  134. + (void)userInitialize:(NSDictionary *)properties;
  135. /// 更新用户属性操作
  136. /// @param properties 属性字典
  137. + (void)userUpdate:(NSDictionary *)properties;
  138. /// 用户属性增加操作
  139. /// @param properties 属性字典 暂时只支持数字属性
  140. + (void)userAdd:(NSDictionary *)properties;
  141. #pragma mark - properties
  142. /// 添加静态事件属性,每个事件都将会发送
  143. /// @param staticProperties 属性字典
  144. + (void)registerStaticProperties:(NSDictionary *)staticProperties;
  145. /// 删除添加的静态事件属性
  146. + (void)clearStaticProperties;
  147. /// 删除添加的某个静态事件属性
  148. /// @param propertyName 属性Key
  149. + (void)unregisterStaticProperty:(NSString *)propertyName;
  150. /// 添加动态事件属性,每次发送事件会调用dynamicPropertiesCaculator
  151. /// @param dynamicPropertiesCaculator 动态属性回调,需返回希望上传的属性字典
  152. + (void)registerDynamicProperties:(NSDictionary* (^)(void))dynamicPropertiesCaculator;
  153. @end
  154. NS_ASSUME_NONNULL_END