JPUSHService.h 36 KB

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