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