NIMSystemNotificationManagerProtocol.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // NIMSystemNotificationManager.h
  3. // NIMLib
  4. //
  5. // Created by Netease.
  6. // Copyright (c) 2015 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @class NIMSession;
  11. @class NIMSystemNotification;
  12. @class NIMCustomSystemNotification;
  13. @class NIMSystemNotificationFilter;
  14. /**
  15. * 系统通知block
  16. *
  17. * @param error 错误,如果成功则error为nil
  18. */
  19. typedef void(^NIMSystemNotificationHandler)(NSError * __nullable error);
  20. /**
  21. * 系统通知委托
  22. */
  23. @protocol NIMSystemNotificationManagerDelegate <NSObject>
  24. @optional
  25. #pragma mark - 系统通知
  26. /**
  27. * 收到系统通知回调
  28. *
  29. * @param notification 系统通知
  30. */
  31. - (void)onReceiveSystemNotification:(NIMSystemNotification *)notification;
  32. /**
  33. * 系统通知数量变化
  34. *
  35. * @param unreadCount 总系统通知未读数目
  36. */
  37. - (void)onSystemNotificationCountChanged:(NSInteger)unreadCount;
  38. #pragma mark - 自定义系统通知
  39. /**
  40. * 收到自定义通知回调
  41. * @param notification 自定义通知
  42. * @discussion 这个通知是由开发者服务端/客户端发出,由我们的服务器进行透传的通知,SDK 不负责这个信息的存储,如果需要上层需要存储,需要在这个方法返回前进行存储
  43. */
  44. - (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification;
  45. @end
  46. /**
  47. * 系统通知协议
  48. */
  49. @protocol NIMSystemNotificationManager <NSObject>
  50. /**
  51. * 获取本地存储的系统通知
  52. *
  53. * @param notification 当前最早系统消息,没有则传入nil
  54. * @param limit 最大获取数
  55. *
  56. * @return 系统消息列表
  57. */
  58. - (nullable NSArray<NIMSystemNotification *> *)fetchSystemNotifications:(nullable NIMSystemNotification *)notification
  59. limit:(NSInteger)limit;
  60. /**
  61. * 获取本地存储的系统通知
  62. *
  63. * @param notification 当前最早系统消息,没有则传入nil
  64. * @param limit 最大获取数
  65. * @param filter 过滤器
  66. *
  67. * @return 系统消息列表
  68. */
  69. - (nullable NSArray<NIMSystemNotification *> *)fetchSystemNotifications:(nullable NIMSystemNotification *)notification
  70. limit:(NSInteger)limit
  71. filter:(nullable NIMSystemNotificationFilter *)filter;
  72. /**
  73. * 未读系统消息数
  74. *
  75. * @return 未读系统消息数
  76. */
  77. - (NSInteger)allUnreadCount;
  78. /**
  79. * 未读系统消息数
  80. *
  81. * @param filter 过滤器
  82. *
  83. * @return 未读系统消息数
  84. */
  85. - (NSInteger)allUnreadCount:(nullable NIMSystemNotificationFilter *)filter;
  86. /**
  87. * 删除单条系统消息
  88. *
  89. * @param notification 系统消息
  90. */
  91. - (void)deleteNotification:(NIMSystemNotification *)notification;
  92. /**
  93. * 删除所有系统消息
  94. */
  95. - (void)deleteAllNotifications;
  96. /**
  97. * 删除所有命中过滤器的系统消息
  98. *
  99. * @param filter 过滤器
  100. */
  101. - (void)deleteAllNotifications:(nullable NIMSystemNotificationFilter *)filter;
  102. /**
  103. * 标记单条系统消息为已读
  104. *
  105. * @param notification 系统消息
  106. */
  107. - (void)markNotificationsAsRead:(NIMSystemNotification *)notification;
  108. /**
  109. * 标记所有系统消息为已读
  110. */
  111. - (void)markAllNotificationsAsRead;
  112. /**
  113. * 标记所有命中过滤器的系统消息为已读
  114. *
  115. * @param filter 过滤器
  116. */
  117. - (void)markAllNotificationsAsRead:(nullable NIMSystemNotificationFilter *)filter;
  118. /**
  119. * 发送自定义系统通知
  120. *
  121. * @param notification 系统通知
  122. * @param session 接收方
  123. * @param completion 发送结果回调
  124. * @discussion 仅支持个人和群。聊天室不支持
  125. */
  126. - (void)sendCustomNotification:(NIMCustomSystemNotification *)notification
  127. toSession:(NIMSession *)session
  128. completion:(nullable NIMSystemNotificationHandler)completion;
  129. /**
  130. * 添加系统消息通知委托
  131. *
  132. * @param delegate 系统通知回调
  133. */
  134. - (void)addDelegate:(id<NIMSystemNotificationManagerDelegate>)delegate;
  135. /**
  136. * 移除系统消息通知委托
  137. *
  138. * @param delegate 系统通知回调
  139. */
  140. - (void)removeDelegate:(id<NIMSystemNotificationManagerDelegate>)delegate;
  141. @end
  142. NS_ASSUME_NONNULL_END