QYCustomMessage.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // QYCustomMessage.h
  3. // QYSDK
  4. //
  5. // Created by Netease on 2018/11/22.
  6. // Copyright © 2018 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /**
  10. * 消息来源类型,默认QYCustomMessageSourceTypeNone
  11. */
  12. typedef NS_ENUM(NSInteger, QYCustomMessageSourceType) {
  13. QYCustomMessageSourceTypeNone = 0, //无,不显示头像
  14. QYCustomMessageSourceTypeSend, //发送方,显示访客头像
  15. QYCustomMessageSourceTypeReceive, //接收方,显示客服头像
  16. };
  17. /**
  18. * QYCustomMessage序列化协议
  19. */
  20. @protocol QYCustomMessageCoding <NSObject>
  21. @optional
  22. /**
  23. * 缩略消息,用以显示在会话列表
  24. */
  25. - (NSString *)thumbText;
  26. /**
  27. * 消息数据序列化,用于数据库存储
  28. */
  29. - (NSDictionary *)encodeMessage;
  30. /**
  31. * 消息数据解码
  32. */
  33. - (void)decodeMessage:(NSDictionary *)content;
  34. /**
  35. * 消息来源
  36. */
  37. - (QYCustomMessageSourceType)messageSourceType;
  38. @end
  39. /**
  40. * 自定义消息基类
  41. * 使用方法:针对需自定义的消息,写子类继承QYCustomMessage,扩展所需属性,并实现QYCustomMessageCoding协议
  42. */
  43. @interface QYCustomMessage : NSObject <QYCustomMessageCoding>
  44. /**
  45. * 消息唯一ID
  46. */
  47. @property (nonatomic, copy, readonly) NSString *messageId;
  48. @end