V2TIMManager+APNS.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // 腾讯云通信服务 IMSDK
  4. //
  5. // 模块名称:V2TIMManager+APNS
  6. //
  7. // 消息推送接口,里面包含了消息的推送的开启逻辑
  8. //
  9. /////////////////////////////////////////////////////////////////////
  10. #import "V2TIMManager.h"
  11. @class V2TIMAPNSConfig;
  12. V2TIM_EXPORT @protocol V2TIMAPNSListener;
  13. V2TIM_EXPORT @interface V2TIMManager (APNS)
  14. /////////////////////////////////////////////////////////////////////////////////
  15. //
  16. // 设置 APNS 推送
  17. //
  18. /////////////////////////////////////////////////////////////////////////////////
  19. /**
  20. * 1.1 设置 APNS 监听
  21. */
  22. - (void)setAPNSListener:(id<V2TIMAPNSListener>)apnsListener;
  23. /**
  24. * 1.2 设置 APNS 推送
  25. *
  26. * config -> token:苹果后台对客户端的唯一标识,需要主动调用系统 API 获取,获取方法如下:
  27. *
  28. * <pre>
  29. * //获取 token 代码示例
  30. * if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
  31. * [[UIApplication sharedApplication] registerUserNotificationSettings:
  32. * [UIUserNotificationSettings settingsForTypes:
  33. * (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
  34. * [[UIApplication sharedApplication] registerForRemoteNotifications];
  35. * }
  36. * else{
  37. * [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
  38. * (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
  39. * }
  40. *
  41. * //收到 token 代码示例
  42. * -(void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  43. * //回调的 deviceToken 就是需要的 token 信息
  44. * }
  45. * </pre>
  46. *
  47. * config -> busiId:推送证书 ID,上传推送证书(p.12)到 IM 控制台后生成。
  48. * 具体步骤请参考 [离线推送](https://cloud.tencent.com/document/product/269/9154)。
  49. *
  50. * @note
  51. * - 接口成功设置后会开启离线推送功能,如果您需要自定义推送的格式信息,请参考 V2TIMManager+Message.h 里面的 sendMessage 接口。
  52. * - 如果成功开启了离线推送,APP 进后台后,如果收到消息,会弹系统推送通知,APP 进前台后,如果收到消息,则不会弹系统推送通知。
  53. * - APP 进后台后 SDK 会默认设置应用角标为所有会话未读数之和,如果您需要自定义 APP 的未读数,请监听 V2TIMAPNSListener 回调设置。
  54. * - APP 在未初始化或未登录成功状态下 SDK 不会设置应用角标,这种情况下如需设置应用角标,请自行调用系统函数设置。
  55. * - 如果您想关闭离线推送,请把 config 设置为 nil。
  56. */
  57. - (void)setAPNS:(V2TIMAPNSConfig*)config succ:(V2TIMSucc)succ fail:(V2TIMFail)fail;
  58. @end
  59. /////////////////////////////////////////////////////////////////////////////////
  60. //
  61. // APNS 监听器
  62. //
  63. /////////////////////////////////////////////////////////////////////////////////
  64. V2TIM_EXPORT @protocol V2TIMAPNSListener <NSObject>
  65. @optional
  66. /** 程序进后台后,自定义 APP 的未读数,如果不处理,APP 未读数默认为所有会话未读数之和
  67. * <pre>
  68. *
  69. * - (uint32_t)onSetAPPUnreadCount {
  70. * return 100; // 自定义未读数
  71. * }
  72. *
  73. * </pre>
  74. */
  75. - (uint32_t)onSetAPPUnreadCount;
  76. @end
  77. /////////////////////////////////////////////////////////////////////////////////
  78. // APNS 配置
  79. /////////////////////////////////////////////////////////////////////////////////
  80. V2TIM_EXPORT @interface V2TIMAPNSConfig : NSObject
  81. /**
  82. * APNS token
  83. */
  84. @property(nonatomic,strong) NSData *token;
  85. /**
  86. * IM 控制台证书 ID,接入 TPNS 时不需要填写
  87. */
  88. @property(nonatomic,assign) int businessID;
  89. /**
  90. * 是否接入配置 TPNS, token 是否是从 TPNS 获取
  91. * @note 该字段已废弃
  92. * - 如果您之前通过 TPNS 接入离线推送,并且在 TPNS 控制台配置推送信息,可以继续按照该方式接入推送功能;
  93. * - 如果您从未接入 TPNS,从未在 TPNS 控制台配置推送信息,IM 将不在支持 TPNS 方式接入离线推送功能, 推荐参照如下方式接入:
  94. * https://cloud.tencent.com/document/product/269/74284
  95. */
  96. @property(nonatomic,assign) BOOL isTPNSToken __attribute__((deprecated("not supported anymore, please use APNs")));
  97. @end