EaseSDKHelper.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /************************************************************
  2. * * Hyphenate CONFIDENTIAL
  3. * __________________
  4. * Copyright (C) 2016 Hyphenate Inc. All rights reserved.
  5. *
  6. * NOTICE: All information contained herein is, and remains
  7. * the property of Hyphenate Inc.
  8. * Dissemination of this information or reproduction of this material
  9. * is strictly forbidden unless prior written permission is obtained
  10. * from Hyphenate Inc.
  11. */
  12. #import <UIKit/UIKit.h>
  13. #import <Foundation/Foundation.h>
  14. //#if ENABLE_LITE == 1
  15. #import <HyphenateLite/HyphenateLite.h>
  16. //#else
  17. //#import <Hyphenate/Hyphenate.h>
  18. //#endif
  19. /** @brief 登录状态变更的通知 */
  20. #define KNOTIFICATION_LOGINCHANGE @"loginStateChange"
  21. /** @brief 实时音视频呼叫 */
  22. #define KNOTIFICATION_CALL @"callOutWithChatter"
  23. /** @brief 关闭实时音视频 */
  24. #define KNOTIFICATION_CALL_CLOSE @"callControllerClose"
  25. /** @brief 群组消息ext的字段,用于存放被@的环信id数组 */
  26. #define kGroupMessageAtList @"em_at_list"
  27. /** @brief 群组消息ext字典中,kGroupMessageAtList字段的值,用于@所有人 */
  28. #define kGroupMessageAtAll @"all"
  29. /** @brief 注册SDK时,是否允许控制台输出log */
  30. #define kSDKConfigEnableConsoleLogger @"SDKConfigEnableConsoleLogger"
  31. /** @brief 使用的SDK是否为Lite版本(即不包含实时音视频功能) */
  32. #define kEaseUISDKConfigIsUseLite @"isUselibHyphenateClientSDKLite"
  33. @interface EaseSDKHelper : NSObject<EMClientDelegate>
  34. /** @brief 当前是否有imagePickerViewController弹出 */
  35. @property (nonatomic) BOOL isShowingimagePicker;
  36. /** @brief 使用的SDK是否为Lite版本(即不包含实时音视频功能) */
  37. @property (nonatomic) BOOL isLite;
  38. + (instancetype)shareHelper;
  39. #pragma mark - init Hyphenate
  40. /*!
  41. @method
  42. @brief 注册3.xSDK,注册远程通知
  43. @param application UIApplication对象
  44. @param launchOptions 启动配置(传入AppDelegate中启动回调的参数,可选)
  45. @param appkey 已注册的appkey
  46. @param apnsCertName 上传的推送证书名
  47. @param otherConfig 注册SDK的额外配置(此方法目前只解析了kSDKConfigEnableConsoleLogger字段)
  48. */
  49. - (void)hyphenateApplication:(UIApplication *)application
  50. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  51. appkey:(NSString *)appkey
  52. apnsCertName:(NSString *)apnsCertName
  53. otherConfig:(NSDictionary *)otherConfig;
  54. #pragma mark - receive remote notification
  55. /*!
  56. @method
  57. @brief 程序在前台收到APNs时,需要调用此方法
  58. @param application UIApplication
  59. @param userInfo 推送内容
  60. */
  61. - (void)hyphenateApplication:(UIApplication *)application
  62. didReceiveRemoteNotification:(NSDictionary *)userInfo;
  63. #pragma mark - send message
  64. /*!
  65. @method
  66. @brief 构建待发送的文本消息
  67. @discussion 向环信id为to的用户发送文本消息
  68. @param text 待发送的文本信息
  69. @param to 消息的接收方环信id
  70. @param messageType 消息的聊天类型
  71. @param messageExt 消息的扩展属性
  72. @result 返回构建完成的消息
  73. */
  74. + (EMMessage *)sendTextMessage:(NSString *)text
  75. to:(NSString *)to
  76. messageType:(EMChatType)messageType
  77. messageExt:(NSDictionary *)messageExt;
  78. /*!
  79. @method
  80. @brief 构建待发送的透传消息
  81. @discussion 向环信id为to的用户发送透传消息
  82. @param action 透传消息的命令内容
  83. @param to 消息的接收方环信id
  84. @param messageType 消息的聊天类型
  85. @param messageExt 消息的扩展属性
  86. @param cmdParams 透传消息命令参数,只是为了兼容老版本,应该使用EMMessage的扩展属性来代替
  87. @result 返回构建完成的消息
  88. */
  89. + (EMMessage *)sendCmdMessage:(NSString *)action
  90. to:(NSString *)to
  91. messageType:(EMChatType)messageType
  92. messageExt:(NSDictionary *)messageExt
  93. cmdParams:(NSArray *)params;
  94. /*!
  95. @method
  96. @brief 构建待发送的位置消息
  97. @discussion 向环信id为to的用户发送位置消息
  98. @param latitude 纬度
  99. @param longitude 经度
  100. @param address 地址信息
  101. @param to 消息的接收方环信id
  102. @param messageType 消息的聊天类型
  103. @param messageExt 消息的扩展属性
  104. @result 返回构建完成的消息
  105. */
  106. + (EMMessage *)sendLocationMessageWithLatitude:(double)latitude
  107. longitude:(double)longitude
  108. address:(NSString *)address
  109. to:(NSString *)to
  110. messageType:(EMChatType)messageType
  111. messageExt:(NSDictionary *)messageExt;
  112. /*!
  113. @method
  114. @brief 构建待发送的图片消息
  115. @discussion 向环信id为to的用户发送图片消息
  116. @param imageData 图片数据(NSData对象)
  117. @param to 消息的接收方环信id
  118. @param messageType 消息的聊天类型
  119. @param messageExt 消息的扩展属性
  120. @result 返回构建完成的消息
  121. */
  122. + (EMMessage *)sendImageMessageWithImageData:(NSData *)imageData
  123. to:(NSString *)to
  124. messageType:(EMChatType)messageType
  125. messageExt:(NSDictionary *)messageExt;
  126. /*!
  127. @method
  128. @brief 构建待发送的图片消息
  129. @discussion 向环信id为to的用户发送图片消息
  130. @param image 图片(UIImage对象)
  131. @param to 消息的接收方环信id
  132. @param messageType 消息的聊天类型
  133. @param messageExt 消息的扩展属性
  134. @result 返回构建完成的消息
  135. */
  136. + (EMMessage *)sendImageMessageWithImage:(UIImage *)image
  137. to:(NSString *)to
  138. messageType:(EMChatType)messageType
  139. messageExt:(NSDictionary *)messageExt;
  140. /*!
  141. @method
  142. @brief 构建待发送的语音消息
  143. @discussion 向环信id为to的用户发送语音消息
  144. @param localPath 录制的语音文件本地路径
  145. @param duration 语音时长
  146. @param to 消息的接收方环信id
  147. @param messageType 消息的聊天类型
  148. @param messageExt 消息的扩展属性
  149. @result 返回构建完成的消息
  150. */
  151. + (EMMessage *)sendVoiceMessageWithLocalPath:(NSString *)localPath
  152. duration:(NSInteger)duration
  153. to:(NSString *)to
  154. messageType:(EMChatType)messageType
  155. messageExt:(NSDictionary *)messageExt;
  156. /*!
  157. @method
  158. @brief 构建待发送的视频消息
  159. @discussion 向环信id为to的用户发送视频消息
  160. @param url 视频文件本地路径url
  161. @param to 消息的接收方环信id
  162. @param messageType 消息的聊天类型
  163. @param messageExt 消息的扩展属性
  164. @result 返回构建完成的消息
  165. */
  166. + (EMMessage *)sendVideoMessageWithURL:(NSURL *)url
  167. to:(NSString *)to
  168. messageType:(EMChatType)messageType
  169. messageExt:(NSDictionary *)messageExt;
  170. #pragma mark - call
  171. @end