MobClick.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //
  2. // MobClick.h
  3. // Analytics
  4. //
  5. // Copyright (C) 2010-2017 Umeng.com . All rights reserved.
  6. #import <UIKit/UIKit.h>
  7. #import <Foundation/Foundation.h>
  8. typedef void(^CallbackBlock)();
  9. /**
  10. 统计的场景类别,默认为普通统计;若使用游戏统计API,则需选择游戏场景类别,如E_UM_NORMAL。
  11. */
  12. typedef NS_ENUM (NSUInteger, eScenarioType)
  13. {
  14. E_UM_NORMAL = 0, // default value
  15. };
  16. @class CLLocation;
  17. @interface MobClick : NSObject <UIAlertViewDelegate>
  18. #pragma mark basics
  19. ///---------------------------------------------------------------------------------------
  20. /// @name 设置
  21. ///---------------------------------------------------------------------------------------
  22. /** 设置 统计场景类型,默认为普通应用统计:E_UM_NORMAL
  23. @param
  24. @return void.
  25. */
  26. + (void)setScenarioType:(eScenarioType)eSType;
  27. /** 开启CrashReport收集, 默认YES(开启状态).
  28. @param value 设置为NO,可关闭友盟CrashReport收集功能.
  29. @return void.
  30. */
  31. + (void)setCrashReportEnabled:(BOOL)value;
  32. #pragma mark event logs
  33. ///---------------------------------------------------------------------------------------
  34. /// @name 页面计时
  35. ///---------------------------------------------------------------------------------------
  36. /** 手动页面时长统计, 记录某个页面展示的时长.
  37. @param pageName 统计的页面名称.
  38. @param seconds 单位为秒,int型.
  39. @return void.
  40. */
  41. + (void)logPageView:(NSString *)pageName seconds:(int)seconds;
  42. /** 自动页面时长统计, 开始记录某个页面展示时长.
  43. 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
  44. 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
  45. @param pageName 统计的页面名称.
  46. @return void.
  47. */
  48. + (void)beginLogPageView:(NSString *)pageName;
  49. /** 自动页面时长统计, 结束记录某个页面展示时长.
  50. 使用方法:必须配对调用beginLogPageView:和endLogPageView:两个函数来完成自动统计,若只调用某一个函数不会生成有效数据。
  51. 在该页面展示时调用beginLogPageView:,当退出该页面时调用endLogPageView:
  52. @param pageName 统计的页面名称.
  53. @return void.
  54. */
  55. + (void)endLogPageView:(NSString *)pageName;
  56. ///---------------------------------------------------------------------------------------
  57. /// @name 事件统计
  58. ///---------------------------------------------------------------------------------------
  59. /** 自定义事件,数量统计.
  60. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  61. @param eventId 网站上注册的事件Id.
  62. @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
  63. @param accumulation 累加值。为减少网络交互,可以自行对某一事件ID的某一分类标签进行累加,再传入次数作为参数。
  64. @return void.
  65. */
  66. + (void)event:(NSString *)eventId; //等同于 event:eventId label:eventId;
  67. /** 自定义事件,数量统计.
  68. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  69. */
  70. + (void)event:(NSString *)eventId label:(NSString *)label; // label为nil或@""时,等同于 event:eventId label:eventId;
  71. /** 自定义事件,数量统计.
  72. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID
  73. */
  74. + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes;
  75. + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes counter:(int)number;
  76. /** 自定义事件,时长统计.
  77. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  78. beginEvent,endEvent要配对使用,也可以自己计时后通过durations参数传递进来
  79. @param eventId 网站上注册的事件Id.
  80. @param label 分类标签。不同的标签会分别进行统计,方便同一事件的不同标签的对比,为nil或空字符串时后台会生成和eventId同名的标签.
  81. @param primarykey 这个参数用于和event_id一起标示一个唯一事件,并不会被统计;对于同一个事件在beginEvent和endEvent 中要传递相同的eventId 和 primarykey
  82. @param millisecond 自己计时需要的话需要传毫秒进来
  83. @return void.
  84. @warning 每个event的attributes不能超过10个
  85. eventId、attributes中key和value都不能使用空格和特殊字符,必须是NSString,且长度不能超过255个字符(否则将截取前255个字符)
  86. id, ts, du是保留字段,不能作为eventId及key的名称
  87. */
  88. + (void)beginEvent:(NSString *)eventId;
  89. /** 自定义事件,时长统计.
  90. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  91. */
  92. + (void)endEvent:(NSString *)eventId;
  93. /** 自定义事件,时长统计.
  94. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  95. */
  96. + (void)beginEvent:(NSString *)eventId label:(NSString *)label;
  97. /** 自定义事件,时长统计.
  98. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  99. */
  100. + (void)endEvent:(NSString *)eventId label:(NSString *)label;
  101. /** 自定义事件,时长统计.
  102. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  103. */
  104. + (void)beginEvent:(NSString *)eventId primarykey :(NSString *)keyName attributes:(NSDictionary *)attributes;
  105. /** 自定义事件,时长统计.
  106. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  107. */
  108. + (void)endEvent:(NSString *)eventId primarykey:(NSString *)keyName;
  109. /** 自定义事件,时长统计.
  110. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  111. */
  112. + (void)event:(NSString *)eventId durations:(int)millisecond;
  113. /** 自定义事件,时长统计.
  114. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  115. */
  116. + (void)event:(NSString *)eventId label:(NSString *)label durations:(int)millisecond;
  117. /** 自定义事件,时长统计.
  118. 使用前,请先到友盟App管理后台的设置->编辑自定义事件 中添加相应的事件ID,然后在工程中传入相应的事件ID.
  119. */
  120. + (void)event:(NSString *)eventId attributes:(NSDictionary *)attributes durations:(int)millisecond;
  121. #pragma mark - user methods
  122. /** active user sign-in.
  123. 使用sign-In函数后,如果结束该PUID的统计,需要调用sign-Off函数
  124. @param puid : user's ID
  125. @param provider : 不能以下划线"_"开头,使用大写字母和数字标识; 如果是上市公司,建议使用股票代码。
  126. @return void.
  127. */
  128. + (void)profileSignInWithPUID:(NSString *)puid;
  129. + (void)profileSignInWithPUID:(NSString *)puid provider:(NSString *)provider;
  130. /** active user sign-off.
  131. 停止sign-in PUID的统计
  132. @return void.
  133. */
  134. + (void)profileSignOff;
  135. ///---------------------------------------------------------------------------------------
  136. /// @name 地理位置设置
  137. /// 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
  138. ///---------------------------------------------------------------------------------------
  139. /** 设置经纬度信息
  140. @param latitude 纬度.
  141. @param longitude 经度.
  142. @return void
  143. */
  144. + (void)setLatitude:(double)latitude longitude:(double)longitude;
  145. /** 设置经纬度信息
  146. @param location CLLocation 经纬度信息
  147. @return void
  148. */
  149. + (void)setLocation:(CLLocation *)location;
  150. ///---------------------------------------------------------------------------------------
  151. /// @name Utility函数
  152. ///---------------------------------------------------------------------------------------
  153. /** 判断设备是否越狱,依据是否存在apt和Cydia.app
  154. */
  155. + (BOOL)isJailbroken;
  156. /** 判断App是否被破解
  157. */
  158. + (BOOL)isPirated;
  159. /** 设置 app secret
  160. @param secret string
  161. @return void.
  162. */
  163. + (void)setSecret:(NSString *)secret;
  164. + (void)setCrashCBBlock:(CallbackBlock)cbBlock;
  165. /** DeepLink事件
  166. @param link 唤起应用的link
  167. @return void.
  168. */
  169. + (void)onDeepLinkReceived:(NSURL *)link;
  170. /**
  171. * 设置预置事件属性 键值对 会覆盖同名的key
  172. */
  173. +(void) registerPreProperties:(NSDictionary *)property;
  174. /**
  175. *
  176. * 删除指定预置事件属性
  177. @param key
  178. */
  179. +(void) unregisterPreProperty:(NSString *)propertyName;
  180. /**
  181. * 获取预置事件所有属性;如果不存在,则返回空。
  182. */
  183. +(NSDictionary *)getPreProperties;
  184. /**
  185. *清空所有预置事件属性。
  186. */
  187. +(void)clearPreProperties;
  188. /**
  189. * 设置关注事件是否首次触发,只关注eventList前五个合法eventID.只要已经保存五个,此接口无效
  190. */
  191. +(void)setFirstLaunchEvent:(NSArray *)eventList;
  192. /** 设置是否自动采集页面, 默认NO(不自动采集).
  193. @param value 设置为YES, umeng SDK 会将自动采集页面信息
  194. */
  195. + (void)setAutoPageEnabled:(BOOL)value;
  196. @end