EMMessage.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*!
  2. * \~chinese
  3. * @header EMMessage.h
  4. * @abstract 聊天消息
  5. * @author Hyphenate
  6. * @version 3.00
  7. *
  8. * \~english
  9. * @header EMMessage.h
  10. * @abstract Chat message
  11. * @author Hyphenate
  12. * @version 3.00
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "EMMessageBody.h"
  16. /*!
  17. * \~chinese
  18. * 聊天类型
  19. *
  20. * \~english
  21. * Chat type
  22. */
  23. typedef enum {
  24. EMChatTypeChat = 0, /*! \~chinese 单聊消息 \~english one to one chat type */
  25. EMChatTypeGroupChat, /*! \~chinese 群聊消息 \~english Group chat type */
  26. EMChatTypeChatRoom, /*! \~chinese 聊天室消息 \~english Chatroom chat type */
  27. } EMChatType;
  28. /*!
  29. * \~chinese
  30. * 消息发送状态
  31. *
  32. * \~english
  33. * Message delivery status
  34. */
  35. typedef enum {
  36. EMMessageStatusPending = 0, /*! \~chinese 发送未开始 \~english Pending */
  37. EMMessageStatusDelivering, /*! \~chinese 正在发送 \~english Delivering */
  38. EMMessageStatusSucceed, /*! \~chinese 发送成功 \~english Succeed */
  39. EMMessageStatusFailed, /*! \~chinese 发送失败 \~english Failed */
  40. } EMMessageStatus;
  41. /*!
  42. * \~chinese
  43. * 消息方向
  44. *
  45. * \~english
  46. * Message direction
  47. */
  48. typedef enum {
  49. EMMessageDirectionSend = 0, /*! \~chinese 发送的消息 \~english Send */
  50. EMMessageDirectionReceive, /*! \~chinese 接收的消息 \~english Receive */
  51. } EMMessageDirection;
  52. /*!
  53. * \~chinese
  54. * 聊天消息
  55. *
  56. * \~english
  57. * Chat message
  58. */
  59. @interface EMMessage : NSObject
  60. /*!
  61. * \~chinese
  62. * 消息的唯一标识符
  63. *
  64. * \~english
  65. * Unique identifier of the message
  66. */
  67. @property (nonatomic, copy) NSString *messageId;
  68. /*!
  69. * \~chinese
  70. * 所属会话的唯一标识符
  71. *
  72. * \~english
  73. * Unique identifier of conversation, the message's container object
  74. */
  75. @property (nonatomic, copy) NSString *conversationId;
  76. /*!
  77. * \~chinese
  78. * 消息的方向
  79. *
  80. * \~english
  81. * Message delivery direction
  82. */
  83. @property (nonatomic) EMMessageDirection direction;
  84. /*!
  85. * \~chinese
  86. * 发送方
  87. *
  88. * \~english
  89. * Message sender
  90. */
  91. @property (nonatomic, copy) NSString *from;
  92. /*!
  93. * \~chinese
  94. * 接收方
  95. *
  96. * \~english
  97. * Message receiver
  98. */
  99. @property (nonatomic, copy) NSString *to;
  100. /*!
  101. * \~chinese
  102. * 时间戳,服务器收到此消息的时间
  103. *
  104. * \~english
  105. * Timestamp, the time of server received the message
  106. */
  107. @property (nonatomic) long long timestamp;
  108. /*!
  109. * \~chinese
  110. * 客户端发送/收到此消息的时间
  111. *
  112. * \~english
  113. * The time of client sends/receives the message
  114. */
  115. @property (nonatomic) long long localTime;
  116. /*!
  117. * \~chinese
  118. * 消息类型
  119. *
  120. * \~english
  121. * Chat type
  122. */
  123. @property (nonatomic) EMChatType chatType;
  124. /*!
  125. * \~chinese
  126. * 消息状态
  127. *
  128. * \~english
  129. * Message delivery status
  130. */
  131. @property (nonatomic) EMMessageStatus status;
  132. /*!
  133. * \~chinese
  134. * 已读回执是否已发送/收到, 对于发送方表示是否已经收到已读回执,对于接收方表示是否已经发送已读回执
  135. *
  136. * \~english
  137. * Acknowledge if the message is read by the receipient. It indicates whether the sender has received a message read acknowledgement; or whether the recipient has sent a message read acknowledgement
  138. */
  139. @property (nonatomic) BOOL isReadAcked;
  140. @property (nonatomic) BOOL isNeedGroupAck;
  141. @property (nonatomic, readonly) int groupAckCount;
  142. /*!
  143. * \~chinese
  144. * 送达回执是否已发送/收到,对于发送方表示是否已经收到送达回执,对于接收方表示是否已经发送送达回执,如果EMOptions设置了enableDeliveryAck,SDK收到消息后会自动发送送达回执
  145. *
  146. * \~english
  147. * Acknowledge if the message is delivered. It indicates whether the sender has received a message deliver acknowledgement; or whether the recipient has sent a message deliver acknowledgement. SDK will automatically send delivery acknowledgement if EMOptions is set to enableDeliveryAck
  148. */
  149. @property (nonatomic) BOOL isDeliverAcked;
  150. /*!
  151. * \~chinese
  152. * 是否已读
  153. *
  154. * \~english
  155. * Whether the message has been read
  156. */
  157. @property (nonatomic) BOOL isRead;
  158. /*!
  159. * \~chinese
  160. * 消息体
  161. *
  162. * \~english
  163. * Message body
  164. */
  165. @property (nonatomic, strong) EMMessageBody *body;
  166. /*!
  167. * \~chinese
  168. * 消息扩展
  169. *
  170. * Key值类型必须是NSString, Value值类型必须是NSString或者 NSNumber类型的 BOOL, int, unsigned in, long long, double.
  171. *
  172. * \~english
  173. * Message extension
  174. *
  175. * Key type must be NSString. Value type must be NSString, or NSNumber object (including int, unsigned in, long long, double, use NSNumber (@YES/@NO) instead of BOOL).
  176. */
  177. @property (nonatomic, copy) NSDictionary *ext;
  178. /*!
  179. * \~chinese
  180. * 初始化消息实例
  181. *
  182. * @param aConversationId 会话ID
  183. * @param aFrom 发送方
  184. * @param aTo 接收方
  185. * @param aBody 消息体实例
  186. * @param aExt 扩展信息
  187. *
  188. * @result 消息实例
  189. *
  190. * \~english
  191. * Initialize a message instance
  192. *
  193. * @param aConversationId Conversation id
  194. * @param aFrom Sender
  195. * @param aTo Receiver
  196. * @param aBody Message body
  197. * @param aExt Message extention
  198. *
  199. * @result Message instance
  200. */
  201. - (id)initWithConversationID:(NSString *)aConversationId
  202. from:(NSString *)aFrom
  203. to:(NSString *)aTo
  204. body:(EMMessageBody *)aBody
  205. ext:(NSDictionary *)aExt;
  206. @end