JPUSHService.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /*
  2. * | | | | \ \ / / | | | | / _______|
  3. * | |____| | \ \/ / | |____| | / /
  4. * | |____| | \ / | |____| | | | _____
  5. * | | | | / \ | | | | | | |____ |
  6. * | | | | / /\ \ | | | | \ \______| |
  7. * | | | | /_/ \_\ | | | | \_________|
  8. *
  9. * Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
  10. */
  11. #define JPUSH_VERSION_NUMBER 4.8.1
  12. #import <Foundation/Foundation.h>
  13. @class CLRegion;
  14. @class UILocalNotification;
  15. @class CLLocation;
  16. @class UNNotificationCategory;
  17. @class UNNotificationSettings;
  18. @class UNNotificationRequest;
  19. @class UNNotification;
  20. @class UIView;
  21. @protocol JPUSHRegisterDelegate;
  22. @protocol JPUSHGeofenceDelegate;
  23. @protocol JPUSHNotiInMessageDelegate;
  24. typedef void (^JPUSHTagsOperationCompletion)(NSInteger iResCode, NSSet *iTags, NSInteger seq);
  25. typedef void (^JPUSHTagValidOperationCompletion)(NSInteger iResCode, NSSet *iTags, NSInteger seq, BOOL isBind);
  26. typedef void (^JPUSHAliasOperationCompletion)(NSInteger iResCode, NSString *iAlias, NSInteger seq);
  27. typedef void (^JPUSHPropertiesOperationCompletion)(NSInteger iResCode, NSDictionary *properties, NSInteger seq);
  28. extern NSString *const kJPFNetworkIsConnectingNotification; // 正在连接中
  29. extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
  30. extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
  31. extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
  32. extern NSString *const kJPFNetworkFailedRegisterNotification; //注册失败
  33. extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
  34. extern NSString *const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
  35. extern NSString *const kJPFServiceErrorNotification; // 错误提示
  36. typedef NS_OPTIONS(NSUInteger, JPAuthorizationOptions) {
  37. JPAuthorizationOptionNone = 0, // the application may not present any UI upon a notification being received
  38. JPAuthorizationOptionBadge = (1 << 0), // the application may badge its icon upon a notification being received
  39. JPAuthorizationOptionSound = (1 << 1), // the application may play a sound upon a notification being received
  40. JPAuthorizationOptionAlert = (1 << 2), // the application may display an alert upon a notification being received
  41. JPAuthorizationOptionCarPlay = (1 << 3), // The ability to display notifications in a CarPlay environment.
  42. JPAuthorizationOptionCriticalAlert NS_AVAILABLE_IOS(12.0) = (1 << 4) , //The ability to play sounds for critical alerts.
  43. JPAuthorizationOptionProvidesAppNotificationSettings NS_AVAILABLE_IOS(12.0) = (1 << 5) , //An option indicating the system should display a button for in-app notification settings.
  44. JPAuthorizationOptionProvisional NS_AVAILABLE_IOS(12.0) = (1 << 6) , //The ability to post noninterrupting notifications provisionally to the Notification Center.
  45. JPAuthorizationOptionAnnouncement NS_AVAILABLE_IOS(13.0) = (1 << 7) , //The ability for Siri to automatically read out messages over AirPods.
  46. };
  47. typedef NS_ENUM(NSUInteger, JPAuthorizationStatus) {
  48. JPAuthorizationNotDetermined = 0, // The user has not yet made a choice regarding whether the application may post user notifications.
  49. JPAuthorizationStatusDenied, // The application is not authorized to post user notifications.
  50. JPAuthorizationStatusAuthorized, // The application is authorized to post user notifications.
  51. JPAuthorizationStatusProvisional NS_AVAILABLE_IOS(12.0), // The application is authorized to post non-interruptive user notifications.
  52. };
  53. /*!
  54. * 通知注册实体类
  55. */
  56. @interface JPUSHRegisterEntity : NSObject
  57. /*!
  58. * 支持的类型
  59. * badge,sound,alert
  60. */
  61. @property (nonatomic, assign) NSInteger types;
  62. /*!
  63. * 注入的类别
  64. * iOS10 UNNotificationCategory
  65. * iOS8-iOS9 UIUserNotificationCategory
  66. */
  67. @property (nonatomic, strong) NSSet *categories;
  68. @end
  69. /*!
  70. * 进行删除、查找推送实体类
  71. */
  72. @interface JPushNotificationIdentifier : NSObject<NSCopying, NSCoding>
  73. @property (nonatomic, copy) NSArray<NSString *> *identifiers; // 推送的标识数组
  74. @property (nonatomic, copy) UILocalNotification *notificationObj NS_DEPRECATED_IOS(4_0, 10_0); // iOS10以下可以传UILocalNotification对象数据,iOS10以上无效
  75. @property (nonatomic, assign) BOOL delivered NS_AVAILABLE_IOS(10_0); // 在通知中心显示的或待推送的标志,默认为NO,YES表示在通知中心显示的,NO表示待推送的
  76. @property (nonatomic, copy) void (^findCompletionHandler)(NSArray *results); // 用于查询回调,调用[findNotification:]方法前必须设置,results为返回相应对象数组,iOS10以下返回UILocalNotification对象数组;iOS10以上根据delivered传入值返回UNNotification或UNNotificationRequest对象数组(delivered传入YES,则返回UNNotification对象数组,否则返回UNNotificationRequest对象数组)
  77. @end
  78. /*!
  79. * 推送通知声音实体类
  80. * iOS10以上有效
  81. */
  82. @interface JPushNotificationSound : NSObject <NSCopying, NSCoding>
  83. @property (nonatomic, copy) NSString *soundName; //普通通知铃声
  84. @property (nonatomic, copy) NSString *criticalSoundName NS_AVAILABLE_IOS(12.0); //警告通知铃声
  85. @property (nonatomic, assign) float criticalSoundVolume NS_AVAILABLE_IOS(12.0); //警告通知铃声音量,有效值在0~1之间,默认为1
  86. @end
  87. /*!
  88. * 推送内容实体类
  89. */
  90. @interface JPushNotificationContent : NSObject<NSCopying, NSCoding>
  91. @property (nonatomic, copy) NSString *title; // 推送标题
  92. @property (nonatomic, copy) NSString *subtitle; // 推送副标题
  93. @property (nonatomic, copy) NSString *body; // 推送内容
  94. @property (nonatomic, copy) NSNumber *badge; // 角标的数字。如果不需要改变角标传@(-1)
  95. @property (nonatomic, copy) NSString *action NS_DEPRECATED_IOS(8_0, 10_0); // 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动",iOS10以上无效)
  96. @property (nonatomic, copy) NSString *categoryIdentifier; // 行为分类标识
  97. @property (nonatomic, copy) NSDictionary *userInfo; // 本地推送时可以设置userInfo来增加附加信息,远程推送时设置的payload推送内容作为此userInfo
  98. @property (nonatomic, copy) NSString *sound; // 声音名称,不设置则为默认声音
  99. @property (nonatomic, copy) JPushNotificationSound *soundSetting NS_AVAILABLE_IOS(10.0); //推送声音实体
  100. @property (nonatomic, copy) NSArray *attachments NS_AVAILABLE_IOS(10_0); // 附件,iOS10以上有效,需要传入UNNotificationAttachment对象数组类型
  101. @property (nonatomic, copy) NSString *threadIdentifier NS_AVAILABLE_IOS(10_0); // 线程或与推送请求相关对话的标识,iOS10以上有效,可用来对推送进行分组
  102. @property (nonatomic, copy) NSString *launchImageName NS_AVAILABLE_IOS(10_0); // 启动图片名,iOS10以上有效,从推送启动时将会用到
  103. @property (nonatomic, copy) NSString *summaryArgument NS_AVAILABLE_IOS(12.0); //插入到通知摘要中的部分参数。iOS12以上有效。
  104. @property (nonatomic, assign) NSUInteger summaryArgumentCount NS_AVAILABLE_IOS(12.0); //插入到通知摘要中的项目数。iOS12以上有效。
  105. @property (nonatomic, copy) NSString *targetContentIdentifier NS_AVAILABLE_IOS(13.0); // An identifier for the content of the notification used by the system to customize the scene to be activated when tapping on a notification.
  106. //iOS15以上的新增属性 interruptionLevel为枚举UNNotificationInterruptionLevel
  107. // The interruption level determines the degree of interruption associated with the notification
  108. @property (nonatomic, assign) NSUInteger interruptionLevel NS_AVAILABLE_IOS(15.0);
  109. // Relevance score determines the sorting for the notification across app notifications. The expected range is between 0.0f and 1.0f.
  110. @property (nonatomic, assign) double relevanceScore NS_AVAILABLE_IOS(15.0);
  111. @end
  112. /*!
  113. * 推送触发方式实体类
  114. * 注:dateComponents、timeInterval、region在iOS10以上可选择其中一个参数传入有效值,如果同时传入值会根据优先级I、II、III使其中一种触发方式生效,fireDate为iOS10以下根据时间触发时须传入的参数
  115. */
  116. @interface JPushNotificationTrigger : NSObject<NSCopying, NSCoding>
  117. @property (nonatomic, assign) BOOL repeat; // 设置是否重复,默认为NO
  118. @property (nonatomic, copy) NSDate *fireDate NS_DEPRECATED_IOS(2_0, 10_0); // 用来设置触发推送的时间,iOS10以上无效
  119. @property (nonatomic, copy) CLRegion *region NS_AVAILABLE_IOS(8_0); // 用来设置触发推送的位置,iOS8以上有效,iOS10以上优先级为I,应用需要有允许使用定位的授权
  120. @property (nonatomic, copy) NSDateComponents *dateComponents NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的日期时间,iOS10以上有效,优先级为II
  121. @property (nonatomic, assign) NSTimeInterval timeInterval NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的时间,iOS10以上有效,优先级为III
  122. @end
  123. /*!
  124. * 注册或更新推送实体类
  125. */
  126. @interface JPushNotificationRequest : NSObject<NSCopying, NSCoding>
  127. @property (nonatomic, copy) NSString *requestIdentifier; // 推送请求标识
  128. @property (nonatomic, copy) JPushNotificationContent *content; // 设置推送的具体内容
  129. @property (nonatomic, copy) JPushNotificationTrigger *trigger; // 设置推送的触发方式
  130. @property (nonatomic, copy) void (^completionHandler)(id result); // 注册或更新推送成功回调,iOS10以上成功则result为UNNotificationRequest对象,失败则result为nil;iOS10以下成功result为UILocalNotification对象,失败则result为nil
  131. @end
  132. /*!
  133. * JPush 核心头文件
  134. */
  135. @interface JPUSHService : NSObject
  136. ///----------------------------------------------------
  137. /// @name Setup 启动相关
  138. ///----------------------------------------------------
  139. /*!
  140. * @abstract 启动SDK
  141. *
  142. * @param launchingOption 启动参数.
  143. * @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识.
  144. * @param channel 发布渠道. 可选.
  145. * @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
  146. * App 证书环境取决于profile provision的配置,此处建议与证书环境保持一致.
  147. *
  148. * @discussion 提供SDK启动必须的参数, 来启动 SDK.
  149. * 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作.
  150. */
  151. + (void)setupWithOption:(NSDictionary *)launchingOption
  152. appKey:(NSString *)appKey
  153. channel:(NSString *)channel
  154. apsForProduction:(BOOL)isProduction;
  155. /*!
  156. * @abstract 启动SDK
  157. *
  158. * @param launchingOption 启动参数.
  159. * @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识.
  160. * @param channel 发布渠道. 可选.
  161. * @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
  162. * App 证书环境取决于profile provision的配置,此处建议与证书环境保持一致.
  163. * @param advertisingId 广告标识符(IDFA) 如果不需要使用IDFA,传nil.
  164. *
  165. * @discussion 提供SDK启动必须的参数, 来启动 SDK.
  166. * 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作.
  167. */
  168. + (void)setupWithOption:(NSDictionary *)launchingOption
  169. appKey:(NSString *)appKey
  170. channel:(NSString *)channel
  171. apsForProduction:(BOOL)isProduction
  172. advertisingIdentifier:(NSString *)advertisingId;
  173. ///----------------------------------------------------
  174. /// @name APNs about 通知相关
  175. ///----------------------------------------------------
  176. /*!
  177. * @abstract 注册要处理的远程通知类型
  178. *
  179. * @param types 通知类型
  180. * @param categories 类别组
  181. *
  182. */
  183. + (void)registerForRemoteNotificationTypes:(NSUInteger)types
  184. categories:(NSSet *)categories;
  185. /*!
  186. * @abstract 新版本的注册方法(兼容iOS10)
  187. *
  188. * @param config 注册通知配置
  189. * @param delegate 代理
  190. *
  191. */
  192. + (void)registerForRemoteNotificationConfig:(JPUSHRegisterEntity *)config delegate:(id<JPUSHRegisterDelegate>)delegate;
  193. + (void)registerDeviceToken:(NSData *)deviceToken;
  194. /*!
  195. * @abstract 处理收到的 APNs 消息
  196. */
  197. + (void)handleRemoteNotification:(NSDictionary *)remoteInfo;
  198. /*!
  199. * @abstract 向极光服务器提交Token
  200. *
  201. * @param voipToken 推送使用的Voip Token
  202. */
  203. + (void)registerVoipToken:(NSData *)voipToken;
  204. /*!
  205. * @abstract 处理收到的 Voip 消息
  206. *
  207. * @param remoteInfo 下发的 Voip 内容
  208. */
  209. + (void)handleVoipNotification:(NSDictionary *)remoteInfo;
  210. /*!
  211. * @abstract 检测通知授权状态
  212. * @param completion 授权结果通过status值返回,详见JPAuthorizationStatus
  213. */
  214. + (void)requestNotificationAuthorization:(void (^)(JPAuthorizationStatus status))completion;
  215. /*!
  216. * @abstract 跳转至系统设置页面,iOS8及以上有效
  217. */
  218. + (void)openSettingsForNotification:(void (^)(BOOL success))completionHandler NS_AVAILABLE_IOS(8_0);
  219. /*!
  220. * Tags操作接口
  221. * 支持增加/覆盖/删除/清空/查询操作
  222. * 详情请参考文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/)
  223. */
  224. /**
  225. 增加tags
  226. @param tags 需要增加的tags集合
  227. @param completion 响应回调
  228. @param seq 请求序列号
  229. */
  230. + (void)addTags:(NSSet<NSString *> *)tags
  231. completion:(JPUSHTagsOperationCompletion)completion
  232. seq:(NSInteger)seq;
  233. /**
  234. 覆盖tags
  235. 调用该接口会覆盖用户所有的tags
  236. @param tags 需要设置的tags集合
  237. @param completion 响应回调
  238. @param seq 请求序列号
  239. */
  240. + (void)setTags:(NSSet<NSString *> *)tags
  241. completion:(JPUSHTagsOperationCompletion)completion
  242. seq:(NSInteger)seq;
  243. /**
  244. 删除指定tags
  245. @param tags 需要删除的tags集合
  246. @param completion 响应回调
  247. @param seq 请求序列号
  248. */
  249. + (void)deleteTags:(NSSet<NSString *> *)tags
  250. completion:(JPUSHTagsOperationCompletion)completion
  251. seq:(NSInteger)seq;
  252. /**
  253. 清空所有tags
  254. @param completion 响应回调
  255. @param seq 请求序列号
  256. */
  257. + (void)cleanTags:(JPUSHTagsOperationCompletion)completion
  258. seq:(NSInteger)seq;
  259. /**
  260. 查询全部tags
  261. @param completion 响应回调,请在回调中获取查询结果
  262. @param seq 请求序列号
  263. */
  264. + (void)getAllTags:(JPUSHTagsOperationCompletion)completion
  265. seq:(NSInteger)seq;
  266. /**
  267. 验证tag是否绑定
  268. @param completion 响应回调,回调中查看是否绑定
  269. @param seq 请求序列号
  270. */
  271. + (void)validTag:(NSString *)tag
  272. completion:(JPUSHTagValidOperationCompletion)completion
  273. seq:(NSInteger)seq;
  274. /**
  275. 设置Alias
  276. @param alias 需要设置的alias
  277. @param completion 响应回调
  278. @param seq 请求序列号
  279. */
  280. + (void)setAlias:(NSString *)alias
  281. completion:(JPUSHAliasOperationCompletion)completion
  282. seq:(NSInteger)seq;
  283. /**
  284. 删除alias
  285. @param completion 响应回调
  286. @param seq 请求序列号
  287. */
  288. + (void)deleteAlias:(JPUSHAliasOperationCompletion)completion
  289. seq:(NSInteger)seq;
  290. /**
  291. 查询当前alias
  292. @param completion 响应回调
  293. @param seq 请求序列号
  294. */
  295. + (void)getAlias:(JPUSHAliasOperationCompletion)completion
  296. seq:(NSInteger)seq;
  297. /*!
  298. * @abstract 过滤掉无效的 tags
  299. *
  300. * @discussion 如果 tags 数量超过限制数量, 则返回靠前的有效的 tags.
  301. * 建议设置 tags 前用此接口校验. SDK 内部也会基于此接口来做过滤.
  302. */
  303. + (NSSet *)filterValidTags:(NSSet *)tags;
  304. /*!
  305. * Property操作接口
  306. * 支持增加/删除/清空操作
  307. * 详情请参考文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/)
  308. */
  309. /**
  310. 新增/更新用户属性
  311. 如果某个用户属性之前已经存在了,则会更新;不存在,则会新增
  312. @param properties 需要新增或者更新的的用户属性内容,类型为NSDictionary;
  313. Key 为用户属性名称,类型必须是 NSString 类型;Value为用户属性值,只支持 NSString、NSNumber、NSDate类型,如果属性为BOOL类型,传值时请转成NSNumber类型
  314. @param completion 响应回调
  315. @param seq 请求序列号
  316. */
  317. + (void)setProperties:(NSDictionary *)properties
  318. completion:(JPUSHPropertiesOperationCompletion)completion
  319. seq:(NSInteger)seq;
  320. /**
  321. 删除指定属性
  322. @param keys 需要删除的属性名称集合
  323. @param completion 响应回调
  324. @param seq 请求序列号
  325. */
  326. + (void)deleteProperties:(NSSet<NSString *> *)keys
  327. completion:(JPUSHPropertiesOperationCompletion)completion
  328. seq:(NSInteger)seq;
  329. /**
  330. 清空所有属性
  331. @param completion 响应回调
  332. @param seq 请求序列号
  333. */
  334. + (void)cleanProperties:(JPUSHPropertiesOperationCompletion)completion
  335. seq:(NSInteger)seq;
  336. ///----------------------------------------------------
  337. /// @name Stats 统计功能
  338. ///----------------------------------------------------
  339. /*!
  340. * @abstract 开始记录页面停留
  341. *
  342. * @param pageName 页面名称
  343. * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics
  344. */
  345. + (void)startLogPageView:(NSString *)pageName __attribute__((deprecated("JCore 1.1.8 版本已过期")));
  346. /*!
  347. * @abstract 停止记录页面停留
  348. *
  349. * @param pageName 页面
  350. * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics
  351. */
  352. + (void)stopLogPageView:(NSString *)pageName __attribute__((deprecated("JCore 1.1.8 版本已过期")));
  353. /*!
  354. * @abstract 直接上报在页面的停留时间
  355. *
  356. * @param pageName 页面
  357. * @param seconds 停留的秒数
  358. * @discussion JCore 1.1.8 版本后,如需统计页面流,请使用 JAnalytics
  359. */
  360. + (void)beginLogPageView:(NSString *)pageName duration:(int)seconds __attribute__((deprecated("JCore 1.1.8 版本已过期")));
  361. /*!
  362. * @abstract 开启Crash日志收集
  363. *
  364. * @discussion 默认是关闭状态.
  365. */
  366. + (void)crashLogON;
  367. /*!
  368. * @abstract 地理位置上报
  369. *
  370. * @param latitude 纬度.
  371. * @param longitude 经度.
  372. *
  373. */
  374. + (void)setLatitude:(double)latitude longitude:(double)longitude;
  375. /*!
  376. * @abstract 地理位置上报
  377. *
  378. * @param location 直接传递 CLLocation * 型的地理信息
  379. *
  380. * @discussion 需要链接 CoreLocation.framework 并且 #import <CoreLocation/CoreLocation.h>
  381. */
  382. + (void)setLocation:(CLLocation *)location;
  383. /**
  384. 设置地理围栏的最大个数
  385. 默认值为 10 ,iOS系统默认地理围栏最大个数为20
  386. @param count 个数 count
  387. */
  388. + (void)setGeofeneceMaxCount:(NSInteger)count;
  389. /**
  390. 设置地理围栏'圈内'类型的检测周期
  391. 默认15分钟检测一次
  392. */
  393. + (void)setGeofenecePeriodForInside:(NSInteger)seconds;
  394. /**
  395. 注册地理围栏的代理
  396. @param delegate 代理
  397. @param launchOptions app启动完成是收到的字段参数
  398. */
  399. + (void)registerLbsGeofenceDelegate:(id<JPUSHGeofenceDelegate>)delegate withLaunchOptions:(NSDictionary *)launchOptions;
  400. /**
  401. 删除地理围栏
  402. @param geofenceId 地理围栏id
  403. */
  404. + (void)removeGeofenceWithIdentifier:(NSString *)geofenceId;
  405. ///----------------------------------------------------
  406. /// @name Local Notification 本地通知
  407. ///----------------------------------------------------
  408. /*!
  409. * @abstract 注册或更新推送 (支持iOS10,并兼容iOS10以下版本)
  410. *
  411. * JPush 2.1.9新接口
  412. * @param request JPushNotificationRequest类型,设置推送的属性,设置已有推送的request.requestIdentifier即更新已有的推送,否则为注册新推送,更新推送仅仅在iOS10以上有效,结果通过request.completionHandler返回
  413. * @discussion 旧的注册本地推送接口被废弃,使用此接口可以替换
  414. *
  415. */
  416. + (void)addNotification:(JPushNotificationRequest *)request;
  417. /*!
  418. * @abstract 移除推送 (支持iOS10,并兼容iOS10以下版本)
  419. *
  420. * JPush 2.1.9新接口
  421. * @param identifier JPushNotificationIdentifier类型,iOS10以上identifier设置为nil,则移除所有在通知中心显示推送和待推送请求,也可以通过设置identifier.delivered和identifier.identifiers来移除相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则移除相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier设置为nil,则移除所有推送,identifier.delivered属性无效,另外可以通过identifier.notificationObj传入特定推送对象来移除此推送。
  422. * @discussion 旧的所有删除推送接口被废弃,使用此接口可以替换
  423. *
  424. */
  425. + (void)removeNotification:(JPushNotificationIdentifier *)identifier;
  426. /*!
  427. * @abstract 查找推送 (支持iOS10,并兼容iOS10以下版本)
  428. *
  429. * JPush 2.1.9新接口
  430. * @param identifier JPushNotificationIdentifier类型,iOS10以上可以通过设置identifier.delivered和identifier.identifiers来查找相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则返回相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier.delivered属性无效,identifier.identifiers如果设置nil或空数组则返回所有未触发的推送。须要设置identifier.findCompletionHandler回调才能得到查找结果,通过(NSArray *results)返回相应对象数组。
  431. * @discussion 旧的查找推送接口被废弃,使用此接口可以替换
  432. *
  433. */
  434. + (void)findNotification:(JPushNotificationIdentifier *)identifier;
  435. /*!
  436. * @abstract 本地推送,最多支持64个
  437. *
  438. * @param fireDate 本地推送触发的时间
  439. * @param alertBody 本地推送需要显示的内容
  440. * @param badge 角标的数字。如果不需要改变角标传-1
  441. * @param alertAction 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动")
  442. * @param notificationKey 本地推送标示符
  443. * @param userInfo 自定义参数,可以用来标识推送和增加附加信息
  444. * @param soundName 自定义通知声音,设置为nil为默认声音
  445. *
  446. * @discussion 最多支持 64 个定义,此方法被[addNotification:]方法取代
  447. */
  448. + (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
  449. alertBody:(NSString *)alertBody
  450. badge:(int)badge
  451. alertAction:(NSString *)alertAction
  452. identifierKey:(NSString *)notificationKey
  453. userInfo:(NSDictionary *)userInfo
  454. soundName:(NSString *)soundName __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  455. /*!
  456. * @abstract 本地推送 (支持 iOS8 新参数)
  457. *
  458. * IOS8新参数
  459. * @param region 自定义参数
  460. * @param regionTriggersOnce 自定义参数
  461. * @param category 自定义参数
  462. * @discussion 此方法被[addNotification:]方法取代
  463. */
  464. + (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
  465. alertBody:(NSString *)alertBody
  466. badge:(int)badge
  467. alertAction:(NSString *)alertAction
  468. identifierKey:(NSString *)notificationKey
  469. userInfo:(NSDictionary *)userInfo
  470. soundName:(NSString *)soundName
  471. region:(CLRegion *)region
  472. regionTriggersOnce:(BOOL)regionTriggersOnce
  473. category:(NSString *)category NS_AVAILABLE_IOS(8_0) __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  474. /*!
  475. * @abstract 前台展示本地推送
  476. *
  477. * @param notification 本地推送对象
  478. * @param notificationKey 需要前台显示的本地推送通知的标示符
  479. *
  480. * @discussion 默认App在前台运行时不会进行弹窗,在程序接收通知调用此接口可实现指定的推送弹窗。--iOS10以下还可继续使用,iOS10以上在[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:]方法中调用completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);即可
  481. */
  482. + (void)showLocalNotificationAtFront:(UILocalNotification *)notification
  483. identifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  484. /*!
  485. * @abstract 删除本地推送定义
  486. *
  487. * @param notificationKey 本地推送标示符
  488. * @discussion 此方法被[removeNotification:]方法取代
  489. */
  490. + (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  491. /*!
  492. * @abstract 删除本地推送定义
  493. * @discussion 此方法被[removeNotification:]方法取代
  494. */
  495. + (void)deleteLocalNotification:(UILocalNotification *)localNotification __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  496. /*!
  497. * @abstract 获取指定通知
  498. *
  499. * @param notificationKey 本地推送标示符
  500. * @return 本地推送对象数组, [array count]为0时表示没找到
  501. * @discussion 此方法被[findNotification:]方法取代
  502. */
  503. + (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  504. /*!
  505. * @abstract 清除所有本地推送对象
  506. * @discussion 此方法被[removeNotification:]方法取代
  507. */
  508. + (void)clearAllLocalNotifications __attribute__((deprecated("JPush 2.1.9 版本已过期")));
  509. ///----------------------------------------------------
  510. /// @name Server badge 服务器端 badge 功能
  511. ///----------------------------------------------------
  512. /*!
  513. * @abstract 设置角标(到服务器)
  514. *
  515. * @param value 新的值. 会覆盖服务器上保存的值(这个用户)
  516. *
  517. * @discussion 本接口不会改变应用本地的角标值.
  518. * 本地仍须调用 UIApplication:setApplicationIconBadgeNumber 函数来设置脚标.
  519. *
  520. * 本接口用于配合 JPush 提供的服务器端角标功能.
  521. * 该功能解决的问题是, 服务器端推送 APNs 时, 并不知道客户端原来已经存在的角标是多少, 指定一个固定的数字不太合理.
  522. *
  523. * JPush 服务器端脚标功能提供:
  524. *
  525. * - 通过本 API 把当前客户端(当前这个用户的) 的实际 badge 设置到服务器端保存起来;
  526. * - 调用服务器端 API 发 APNs 时(通常这个调用是批量针对大量用户),
  527. * 使用 "+1" 的语义, 来表达需要基于目标用户实际的 badge 值(保存的) +1 来下发通知时带上新的 badge 值;
  528. */
  529. + (BOOL)setBadge:(NSInteger)value;
  530. /*!
  531. * @abstract 重置脚标(为0)
  532. *
  533. * @discussion 相当于 [setBadge:0] 的效果.
  534. * 参考 [JPUSHService setBadge:] 说明来理解其作用.
  535. */
  536. + (void)resetBadge;
  537. ///----------------------------------------------------
  538. /// @name Other Feature 其他功能
  539. ///----------------------------------------------------
  540. /*!
  541. * @abstract 设置手机号码(到服务器)
  542. *
  543. * @param mobileNumber 手机号码. 会与用户信息一一对应。可为空,为空则清除号码
  544. * @param completion 响应回调。成功则error为空,失败则error带有错误码及错误信息
  545. *
  546. * @discussion 设置手机号码后,可实现“推送不到短信到”的通知方式,提高推送达到率。结果信息通过completion异步返回,也可将completion设置为nil不处理结果信息。
  547. *
  548. */
  549. + (void)setMobileNumber:(NSString *)mobileNumber completion:(void (^)(NSError *error))completion;
  550. ///----------------------------------------------------
  551. /// @name Logs and others 日志与其他
  552. ///----------------------------------------------------
  553. /*!
  554. * @abstract JPush标识此设备的 registrationID
  555. *
  556. * @discussion SDK注册成功后, 调用此接口获取到 registrationID 才能够获取到.
  557. *
  558. * JPush 支持根据 registrationID 来进行推送.
  559. * 如果你需要此功能, 应该通过此接口获取到 registrationID 后, 上报到你自己的服务器端, 并保存下来.
  560. * registrationIDCompletionHandler:是新增的获取registrationID的方法,需要在block中获取registrationID,resCode为返回码,模拟器调用此接口resCode返回1011,registrationID返回nil.
  561. * 更多的理解请参考 JPush 的文档网站.
  562. */
  563. + (NSString *)registrationID;
  564. + (void)registrationIDCompletionHandler:(void(^)(int resCode,NSString *registrationID))completionHandler;
  565. /*!
  566. * @abstract 打开日志级别到 Debug
  567. *
  568. * @discussion JMessage iOS 的日志系统参考 Android 设计了级别.
  569. * 从低到高是: Verbose, Debug, Info, Warning, Error.
  570. * 对日志级别的进一步理解, 请参考 Android 相关的说明.
  571. *
  572. * SDK 默认开启的日志级别为: Info. 只显示必要的信息, 不打印调试日志.
  573. *
  574. * 请在SDK启动后调用本接口,调用本接口可打开日志级别为: Debug, 打印调试日志.
  575. */
  576. + (void)setDebugMode;
  577. /*!
  578. * @abstract 关闭日志
  579. *
  580. * @discussion 关于日志级别的说明, 参考 [JPUSHService setDebugMode]
  581. *
  582. * 虽说是关闭日志, 但还是会打印 Warning, Error 日志. 这二种日志级别, 在程序运行正常时, 不应有打印输出.
  583. *
  584. * 建议在发布的版本里, 调用此接口, 关闭掉日志打印.
  585. */
  586. + (void)setLogOFF;
  587. /*!
  588. * @abstract 设置SDK地理位置权限开关
  589. *
  590. * @discussion 关闭地理位置之后,SDK地理围栏的相关功能将受到影响,默认是开启。
  591. *
  592. */
  593. + (void)setLocationEanable:(BOOL)isEanble;
  594. /*!
  595. * @abstract 设置应用内提醒消息的代理
  596. *
  597. * @discussion 遵守JPushNotiInMessageDelegate的代理对象
  598. *
  599. */
  600. + (void)setNotiInMessageDelegate:(id<JPUSHNotiInMessageDelegate>)notiInMessageDelegate;
  601. ///----------------------------------------------------
  602. ///********************下列方法已过期********************
  603. ///**************请使用新版tag/alias操作接口**************
  604. ///----------------------------------------------------
  605. /// @name Tag alias setting 设置别名与标签
  606. ///----------------------------------------------------
  607. /*!
  608. * 下面的接口是可选的
  609. * 设置标签和(或)别名(若参数为nil,则忽略;若是空对象,则清空;详情请参考文档:https://docs.jiguang.cn/jpush/client/iOS/ios_api/)
  610. * setTags:alias:fetchCompletionHandle:是新的设置标签别名的方法,不再需要显示声明回调函数,只需要在block里面处理设置结果即可.
  611. * WARN: 使用block时需要注意循环引用问题
  612. */
  613. + (void) setTags:(NSSet *)tags
  614. alias:(NSString *)alias
  615. callbackSelector:(SEL)cbSelector
  616. target:(id)theTarget __attribute__((deprecated("JPush 2.1.1 版本已过期")));
  617. + (void) setTags:(NSSet *)tags
  618. alias:(NSString *)alias
  619. callbackSelector:(SEL)cbSelector
  620. object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期")));
  621. + (void) setTags:(NSSet *)tags
  622. callbackSelector:(SEL)cbSelector
  623. object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期")));
  624. + (void)setTags:(NSSet *)tags
  625. alias:(NSString *)alias
  626. fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler __attribute__((deprecated("JPush 3.0.6 版本已过期")));
  627. + (void) setTags:(NSSet *)tags
  628. aliasInbackground:(NSString *)alias __attribute__((deprecated("JPush 3.0.6 版本已过期")));
  629. + (void)setAlias:(NSString *)alias
  630. callbackSelector:(SEL)cbSelector
  631. object:(id)theTarget __attribute__((deprecated("JPush 3.0.6 版本已过期")));
  632. @end
  633. @class UNUserNotificationCenter;
  634. @class UNNotificationResponse;
  635. @protocol JPUSHRegisterDelegate <NSObject>
  636. /*
  637. * @brief handle UserNotifications.framework [willPresentNotification:withCompletionHandler:]
  638. * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心
  639. * @param notification 前台得到的的通知对象
  640. * @param completionHandler 该callback中的options 请使用UNNotificationPresentationOptions
  641. */
  642. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger options))completionHandler;
  643. /*
  644. * @brief handle UserNotifications.framework [didReceiveNotificationResponse:withCompletionHandler:]
  645. * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心
  646. * @param response 通知响应对象
  647. * @param completionHandler
  648. */
  649. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler;
  650. /*
  651. * @brief handle UserNotifications.framework [openSettingsForNotification:]
  652. * @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心
  653. * @param notification 当前管理的通知对象
  654. */
  655. - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification NS_AVAILABLE_IOS(12.0);
  656. /**
  657. * 监测通知授权状态返回的结果
  658. * @param status 授权通知状态,详见JPAuthorizationStatus
  659. * @param info 更多信息,预留参数
  660. */
  661. - (void)jpushNotificationAuthorization:(JPAuthorizationStatus)status withInfo:(NSDictionary *)info;
  662. @end
  663. @protocol JPUSHGeofenceDelegate <NSObject>
  664. /**
  665. 触发地理围栏
  666. @param geofence 地理围栏触发时返回的信息
  667. @param error 错误信息
  668. */
  669. - (void)jpushGeofenceRegion:(NSDictionary *)geofence
  670. error:(NSError *)error;
  671. /**
  672. 拉取地理围栏列表的回调
  673. @param geofenceList 地理围栏列表
  674. */
  675. - (void)jpushCallbackGeofenceReceived:(NSArray<NSDictionary*> *)geofenceList;
  676. /**
  677. 进入地理围栏区域
  678. @param geofenceId 地理围栏id
  679. @param userInfo 地理围栏触发时返回的信息
  680. @param error 错误信息
  681. */
  682. - (void)jpushGeofenceIdentifer:(NSString *)geofenceId didEnterRegion:(NSDictionary *)userInfo error:(NSError *)error __attribute__((deprecated("JPush 3.6.0 版本已过期")));
  683. /**
  684. 离开地理围栏区域
  685. @param geofenceId 地理围栏id
  686. @param userInfo 地理围栏触发时返回的信息
  687. @param error 错误信息
  688. */
  689. - (void)jpushGeofenceIdentifer:(NSString *)geofenceId didExitRegion:(NSDictionary *)userInfo error:(NSError *)error __attribute__((deprecated("JPush 3.6.0 版本已过期")));
  690. @end
  691. @protocol JPUSHNotiInMessageDelegate <NSObject>
  692. /**
  693. 应用内提醒消息展示的回调
  694. @param content 应用内提醒消息的内容
  695. */
  696. - (void)jPushNotiInMessageDidShowWithContent:(NSDictionary *)content;
  697. /**
  698. 应用内提醒消息点击的回调
  699. @param content 应用内提醒消息的内容
  700. */
  701. - (void)jPushNotiInMessageDidClickWithContent:(NSDictionary *)content;
  702. @end