TapDB.h 8.1 KB

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