EaseSDKHelper.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 <HyphenateLite/HyphenateLite.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. appkey:(NSString *)appkey
  51. apnsCertName:(NSString *)apnsCertName;
  52. #pragma mark - receive remote notification
  53. /*!
  54. @method
  55. @brief 程序在前台收到APNs时,需要调用此方法
  56. @param application UIApplication
  57. @param userInfo 推送内容
  58. */
  59. - (void)hyphenateApplication:(UIApplication *)application
  60. didReceiveRemoteNotification:(NSDictionary *)userInfo;
  61. /// 点击登陆后的操作 - 登录环信
  62. /// @param username <#username description#>
  63. /// @param password <#password description#>
  64. - (void)loginEaseWithUsername:(NSString *)username
  65. password:(NSString *)password;
  66. /// 退出环信
  67. - (void)easeLogout;
  68. /*!
  69. @method
  70. @brief 构建待发送的文本消息
  71. @discussion 向环信id为to的用户发送文本消息
  72. @param text 待发送的文本信息
  73. @param to 消息的接收方环信id
  74. @param messageType 消息的聊天类型
  75. @param messageExt 消息的扩展属性
  76. @result 返回构建完成的消息
  77. */
  78. + (EMMessage *)sendTextMessage:(NSString *)text
  79. to:(NSString *)to
  80. messageType:(EMChatType)messageType
  81. messageExt:(NSDictionary *)messageExt;
  82. /*!
  83. @method
  84. @brief 构建待发送的透传消息
  85. @discussion 向环信id为to的用户发送透传消息
  86. @param action 透传消息的命令内容
  87. @param to 消息的接收方环信id
  88. @param messageType 消息的聊天类型
  89. @param messageExt 消息的扩展属性
  90. @param cmdParams 透传消息命令参数,只是为了兼容老版本,应该使用EMMessage的扩展属性来代替
  91. @result 返回构建完成的消息
  92. */
  93. + (EMMessage *)sendCmdMessage:(NSString *)action
  94. to:(NSString *)to
  95. messageType:(EMChatType)messageType
  96. messageExt:(NSDictionary *)messageExt
  97. cmdParams:(NSArray *)params;
  98. /*!
  99. @method
  100. @brief 构建待发送的位置消息
  101. @discussion 向环信id为to的用户发送位置消息
  102. @param latitude 纬度
  103. @param longitude 经度
  104. @param address 地址信息
  105. @param to 消息的接收方环信id
  106. @param messageType 消息的聊天类型
  107. @param messageExt 消息的扩展属性
  108. @result 返回构建完成的消息
  109. */
  110. + (EMMessage *)sendLocationMessageWithLatitude:(double)latitude
  111. longitude:(double)longitude
  112. address:(NSString *)address
  113. to:(NSString *)to
  114. messageType:(EMChatType)messageType
  115. messageExt:(NSDictionary *)messageExt;
  116. /*!
  117. @method
  118. @brief 构建待发送的图片消息
  119. @discussion 向环信id为to的用户发送图片消息
  120. @param imageData 图片数据(NSData对象)
  121. @param to 消息的接收方环信id
  122. @param messageType 消息的聊天类型
  123. @param messageExt 消息的扩展属性
  124. @result 返回构建完成的消息
  125. */
  126. + (EMMessage *)sendImageMessageWithImageData:(NSData *)imageData
  127. to:(NSString *)to
  128. messageType:(EMChatType)messageType
  129. messageExt:(NSDictionary *)messageExt;
  130. /*!
  131. @method
  132. @brief 构建待发送的图片消息
  133. @discussion 向环信id为to的用户发送图片消息
  134. @param image 图片(UIImage对象)
  135. @param to 消息的接收方环信id
  136. @param messageType 消息的聊天类型
  137. @param messageExt 消息的扩展属性
  138. @result 返回构建完成的消息
  139. */
  140. + (EMMessage *)sendImageMessageWithImage:(UIImage *)image
  141. to:(NSString *)to
  142. messageType:(EMChatType)messageType
  143. messageExt:(NSDictionary *)messageExt;
  144. /*!
  145. @method
  146. @brief 构建待发送的语音消息
  147. @discussion 向环信id为to的用户发送语音消息
  148. @param localPath 录制的语音文件本地路径
  149. @param duration 语音时长
  150. @param to 消息的接收方环信id
  151. @param messageType 消息的聊天类型
  152. @param messageExt 消息的扩展属性
  153. @result 返回构建完成的消息
  154. */
  155. + (EMMessage *)sendVoiceMessageWithLocalPath:(NSString *)localPath
  156. duration:(NSInteger)duration
  157. to:(NSString *)to
  158. messageType:(EMChatType)messageType
  159. messageExt:(NSDictionary *)messageExt;
  160. // 将得到的deviceToken传给SDK
  161. - (void)application:(UIApplication *)application
  162. didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken ;
  163. /// 获取所有会话列表
  164. - (NSArray*)getAllConversations;
  165. /// 发送消息
  166. /// @param aMessage <#aMessage description#>
  167. /// @param aProgressBlock <#aProgressBlock description#>
  168. /// @param aCompletionBlock <#aCompletionBlock description#>
  169. + (void)sendMessage:(EMMessage *)aMessage
  170. progress:(void (^)(int progress))aProgressBlock
  171. completion:(void (^)(EMMessage *message, EMError *error))aCompletionBlock;
  172. @end