QYSessionViewController.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. //
  2. // QYSessionViewController.h
  3. // QYSDK
  4. //
  5. // Created by Netease on 12/21/15.
  6. // Copyright (c) 2017 Netease. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "QYEvaluation.h"
  10. @class QYSource;
  11. @class QYStaffInfo;
  12. @class QYCommodityInfo;
  13. @class QYSelectedCommodityInfo;
  14. /**
  15. * QYSessionViewDelegate:右上角入口以及聊天内容区域按钮点击回调
  16. */
  17. @protocol QYSessionViewDelegate <NSObject>
  18. /**
  19. * 点击右上角按钮回调(对于平台电商来说,这里可以考虑放“商铺入口”)
  20. */
  21. - (void)onTapShopEntrance;
  22. /**
  23. * 点击聊天内容区域的按钮回调(对于平台电商来说,这里可以考虑放置“会话列表入口“)
  24. */
  25. - (void)onTapSessionListEntrance;
  26. @end
  27. /**
  28. * 输入区域上方工具栏内按钮信息类:QYButtonInfo
  29. * 注: actionType及index为button点击事件传递信息,仅可读
  30. * actionType为1表示发送文本消息title,2表示openURL或是自定义行为;index表示该button位置
  31. */
  32. @interface QYButtonInfo : NSObject
  33. @property (nonatomic, strong) id buttonId;
  34. @property (nonatomic, copy) NSString *title;
  35. @property (nonatomic, strong) id userData;
  36. @property (nonatomic, assign, readonly) NSUInteger actionType;
  37. @property (nonatomic, assign, readonly) NSUInteger index;
  38. @end
  39. /**
  40. * 通用完成回调
  41. */
  42. typedef void (^QYCompletion)(BOOL success, NSError *error);
  43. /**
  44. * 工具栏内按钮点击回调定义
  45. */
  46. typedef void (^QYButtonClickBlock)(QYButtonInfo *action);
  47. /**
  48. * 拍摄视频完成回调
  49. * @param filePath 视频存储路径
  50. */
  51. typedef void (^QYVideoCompletion)(NSString *filePath);
  52. /**
  53. * 选择文件完成回调
  54. * @param filePath 文件存储路径
  55. */
  56. typedef void (^QYFileCompletion)(NSString *fileName, NSString *filePath);
  57. /**
  58. * 会话类:QYSessionViewController
  59. * 客服会话ViewController,必须嵌入到UINavigationcontroller中
  60. */
  61. @interface QYSessionViewController : UIViewController
  62. /**
  63. * 会话窗口标题
  64. */
  65. @property (nonatomic, copy) NSString *sessionTitle;
  66. /**
  67. * 访客分流 分组Id
  68. */
  69. @property (nonatomic, assign) int64_t groupId;
  70. /**
  71. * 访客分流 客服Id
  72. */
  73. @property (nonatomic, assign) int64_t staffId;
  74. /**
  75. * 机器人Id
  76. */
  77. @property (nonatomic, assign) int64_t robotId;
  78. /**
  79. * vip等级
  80. */
  81. @property (nonatomic, assign) NSInteger vipLevel;
  82. /**
  83. * 访客分流 是否开启机器人
  84. * @discussion 仅设置staffId/groupId时生效
  85. */
  86. @property (nonatomic, assign) BOOL openRobotInShuntMode;
  87. /**
  88. * 常见问题 模板Id
  89. */
  90. @property (nonatomic, assign) int64_t commonQuestionTemplateId;
  91. /**
  92. * 机器人欢迎语 模板Id
  93. */
  94. @property (nonatomic, assign) int64_t robotWelcomeTemplateId;
  95. /**
  96. * 多入口分流 模板Id
  97. */
  98. @property (nonatomic, assign) int64_t shuntTemplateId;
  99. /**
  100. * 会话窗口来源
  101. */
  102. @property (nonatomic, strong) QYSource *source;
  103. /**
  104. * 商品信息展示
  105. */
  106. @property (nonatomic, strong) QYCommodityInfo *commodityInfo;
  107. /**
  108. * 商品消息是否支持长按复制urlString信息,默认为YES
  109. */
  110. @property (nonatomic, assign) BOOL canCopyCommodityInfo;
  111. /**
  112. * 人工客服信息
  113. */
  114. @property (nonatomic, strong) QYStaffInfo *staffInfo;
  115. /**
  116. * 输入区域上方工具栏内的按钮信息
  117. */
  118. @property (nonatomic, copy) NSArray<QYButtonInfo *> *buttonInfoArray;
  119. /**
  120. * 输入区域上方工具栏内的按钮点击回调
  121. */
  122. @property (nonatomic, copy) QYButtonClickBlock buttonClickBlock;
  123. /**
  124. * 机器人自动发送商品信息功能
  125. */
  126. @property (nonatomic, assign) BOOL autoSendInRobot;
  127. /**
  128. * 每页消息加载的最大数量,默认为20条
  129. */
  130. @property (nonatomic, assign) NSInteger messagePageLimit;
  131. /**
  132. * 是否收起历史消息,默认为NO;若设置为YES,进入会话界面时若需创建新会话,则收起历史消息
  133. */
  134. @property (nonatomic, assign) BOOL hideHistoryMessages;
  135. /**
  136. * 历史消息提示文案,默认为“——以上为历史消息——”;仅在hideHistoryMessages为YES,首次下拉历史消息时展示
  137. */
  138. @property (nonatomic, copy) NSString *historyMessagesTip;
  139. /** 以下为客服相关接口 **/
  140. /**
  141. * 请求人工客服
  142. */
  143. - (void)requestHumanStaff;
  144. /**
  145. * 切换人工客服,客服ID、客服分组ID二者选择一种即可
  146. *
  147. * @param staffId 客服ID
  148. * @param groupId 客服分组ID
  149. * @param closetip 切换提示语
  150. * @param closeCompletion 退出旧会话完成的回调
  151. * @param requestCompletion 请求新会话完成的回调
  152. */
  153. - (void)changeHumanStaffWithStaffId:(int64_t)staffId
  154. groupId:(int64_t)groupId
  155. closetip:(NSString *)closetip
  156. closeCompletion:(QYCompletion)closeCompletion
  157. requestCompletion:(QYCompletion)requestCompletion;
  158. /** 以下为发送相关接口 **/
  159. /**
  160. * 发送文本消息
  161. */
  162. - (void)sendText:(NSString *)text;
  163. /**
  164. * 发送图片消息
  165. */
  166. - (void)sendPicture:(UIImage *)picture;
  167. /**
  168. * 发送视频消息
  169. */
  170. - (void)sendVideo:(NSString *)filePath;
  171. /**
  172. * 发送文件消息
  173. */
  174. - (void)sendFileName:(NSString *)fileName filePath:(NSString *)filePath;
  175. /**
  176. * 发送商品信息展示
  177. */
  178. - (void)sendCommodityInfo:(QYCommodityInfo *)commodityInfo;
  179. /**
  180. * 发送订单列表中选中的商品信息
  181. */
  182. - (void)sendSelectedCommodityInfo:(QYSelectedCommodityInfo *)commodityInfo;
  183. /** 以下为开放能力接口 **/
  184. /**
  185. * 退出会话/退出排队
  186. * @param popViewController 是否退出聊天界面,设置为YES,无论退出是否成功均退出聊天界面
  187. * @param completion 退出完成回调
  188. */
  189. - (void)closeSession:(BOOL)popViewController completion:(QYCompletion)completion;
  190. /**
  191. * 拍摄视频
  192. * 自动发送
  193. */
  194. - (void)shootVideoWithCompletion:(QYVideoCompletion)completion;
  195. /**
  196. * 选择系统文件,调用系统控件UIDocumentPickerViewController,注意文件功能目前仅支持iOS11以上系统
  197. * @param allowedUTIs 需增加支持的文件类型,已有部分默认类型,传nil时采用默认类型组;具体可参照UIDocumentPickerViewController的allowedUTIs参数
  198. * @param completion 选择完成回调
  199. */
  200. - (void)selectFileWithDocumentTypes:(NSArray <NSString *>*)allowedUTIs completion:(QYFileCompletion)completion;
  201. /**
  202. * 弹出工单页面自助提工单
  203. * @param templateID 工单模板ID
  204. */
  205. - (void)presentWorkOrderViewControllerWithTemplateID:(long long)templateID;
  206. /** 以下为自定义视图相关接口 **/
  207. /**
  208. * 注册聊天界面顶部悬停视图
  209. *
  210. * @param hoverView 顶部悬停视图
  211. * @param height 视图高度
  212. * @param insets 视图边距,默认UIEdgeInsetsZero;top表示视图与导航栏底部距离,bottom设置无效,left/right分别表示距离屏幕左右边距
  213. */
  214. - (void)registerTopHoverView:(UIView *)hoverView height:(CGFloat)height marginInsets:(UIEdgeInsets)insets;
  215. /**
  216. * 销毁聊天界面顶部悬停视图
  217. */
  218. - (void)destroyTopHoverViewWithAnmation:(BOOL)animated duration:(NSTimeInterval)duration;
  219. /** 以下为满意度评价相关接口 **/
  220. /**
  221. * 满意度评价事件回调
  222. *
  223. * @param data 评价数据,包括评价模式、选项及标签、上次评价结果等数据,据此构建评价界面
  224. */
  225. typedef void (^QYEvaluationBlock)(QYEvaluactionData *data);
  226. /**
  227. * 评价结果回调
  228. *
  229. * @param state 结果
  230. */
  231. typedef void (^QYEvaluationCompletion)(QYEvaluationState state);
  232. /**
  233. * 人工满意度评价事件
  234. */
  235. @property (nonatomic, copy) QYEvaluationBlock evaluationBlock;
  236. /**
  237. * 机器人满意度评价事件
  238. */
  239. @property (nonatomic, copy) QYEvaluationBlock robotEvaluationBlock;
  240. /**
  241. * 发送人工满意度评价结果
  242. */
  243. - (void)sendEvaluationResult:(QYEvaluactionResult *)result completion:(QYEvaluationCompletion)completion;
  244. /**
  245. * 发送机器人满意度评价结果
  246. */
  247. - (void)sendRobotEvaluationResult:(QYEvaluactionResult *)result completion:(QYEvaluationCompletion)completion;
  248. @end