第三方聊天---環(huán)信

環(huán)信 聊天

 框架
    App
    Easy UI    (UI控件)
    SDK        基于核心協(xié)議實現(xiàn)的完整的 IM 功能,實現(xiàn)了不同類型消息的收發(fā)定拟、會話管理伦腐、群組缴淋、好友、聊天室等功能
    SDK_CORE   為核心的消息同步協(xié)議實現(xiàn)吕座,完成與服務(wù)器之間的信息交換
 
 SDK
    EMClient               SDK的入口盈匾,主要完成登錄忿薇、退出弦追、連接管理等功能岳链,也是獲取其他模塊的入口。
    EMClientManager        管理消息的收發(fā)骗卜,完成會話管理等功能
    EMContactManager       負責(zé)好友的添加刪除宠页,黑名單的管理
    EMGroupManager         負責(zé)群組的管理,創(chuàng)建寇仓、刪除群組,管理群組成員等功能
    EMChatroomManager      負責(zé)聊天室的管理

配置

1. 蘋果開發(fā)官網(wǎng)創(chuàng)建 2推送證書(開發(fā)證書 和 線上證書)
2. 環(huán)信開發(fā)者中心注冊應(yīng)用(添加上述2推送證書)(獲取KEY)
pod 'Hyphenate'     包含實時語音功能
pod 'EaseUI'        快速集成UI
#import <Hyphenate/Hyphenate.h>
AppDelegate
    
    // 在環(huán)信中注冊本應(yīng)用
    EMOptions *options=[EMOptions optionsWithAppkey:@"64619039#kachamao"];
    // 證書
#if DEBUG
    [options setApnsCertName:@"s_dev"];
#else
    [options setApnsCertName:@"s_product"];
#endif
    [[EMClient sharedClient]initializeSDKWithOptions:options];

 
// APP進入后臺
- (void)applicationDidEnterBackground:(UIApplication *)application{
    // 環(huán)信進入后臺
    [[EMClient sharedClient] applicationDidEnterBackground:application];
}


// APP將要從后臺返回前臺
- (void)applicationWillEnterForeground:(UIApplication *)application{
    // 環(huán)信即將進入前臺
    [[EMClient sharedClient] applicationWillEnterForeground:application];
}

注冊登錄

注冊
EMError *error = [[EMClient sharedClient] registerWithUsername:@"唯一表示用戶" password:@"111111"];
if (error==nil) {
    NSLog(@"注冊成功");
}


登陸
[[EMClient sharedClient] loginWithUsername:@"8001"
                                  password:@"111111"
                                completion:^(NSString *aUsername, EMError *aError) {
                                    if (!aError) {
                                        NSLog(@"登錄成功");
                                    } else {
                                        NSLog(@"登錄失敗");
                                    }
                                }];



// 以下情況會導(dǎo)致自動登錄失敗
  1.用戶調(diào)用了 SDK 的登出動作烤宙;
  2.用戶在別的設(shè)備上更改了密碼遍烦,導(dǎo)致此設(shè)備上自動登錄失敗躺枕;
  3.用戶的賬號被從服務(wù)器端刪除服猪;
  4.用戶從另一個設(shè)備登錄供填,把當(dāng)前設(shè)備上登錄的用戶踢出。
自動登錄
BOOL isAutoLogin = [EMClient sharedClient].options.isAutoLogin;
if (!isAutoLogin) {
    EMError *error = [[EMClient sharedClient] loginWithUsername:@"8001" password:@"111111"];
    if (!error)
    {
        [[EMClient sharedClient].options setIsAutoLogin:YES];
    }
}
// 自動登錄后調(diào)用
- (void)autoLoginDidCompleteWithError:(EMError *)error{}
// 重連時回調(diào)
- (void)connectionStateDidChange:(EMConnectionState)aConnectionState{}



退出登錄
  -》主動退出登錄:調(diào)用 SDK 的退出接口罢猪;
  -》被動退出登錄:1. 正在登錄的賬號在另一臺設(shè)備上登錄近她;2. 正在登錄的賬號被從服務(wù)器端刪除。

// 主動退出登錄
EMError *error = [[EMClient sharedClient] logout:YES];
if (!error) {
    NSLog(@"退出成功");
}
// 當(dāng)用戶從另一個設(shè)備登錄此賬號時調(diào)用
- (void)userAccountDidLoginFromOtherDevice{}
// 當(dāng)用戶的賬號被從服務(wù)器端刪除時調(diào)用
- (void)userAccountDidRemoveFromServer{}

好友

// 從服務(wù)器獲取所有的好友
[[EMClient sharedClient].contactManager getContactsFromServerWithCompletion:^(NSArray *aList, EMError *aError) {
    if (!aError) {
        NSLog(@"獲取成功");
    }
}];
// 從數(shù)據(jù)庫獲取所有的好友
NSArray *userlist = [[EMClient sharedClient].contactManager getContacts];
// 發(fā)送 添加好友 申請
[[EMClient sharedClient].contactManager addContact:@"8001"
                                           message:@"我想加您為好友"
                                        completion:^(NSString *aUsername, EMError *aError) {
                                            if (!aError) {
                                                NSLog(@"邀請發(fā)送成功");
                                            }
                                        }];

// 同意好友申請
[[EMClient sharedClient].contactManager approveFriendRequestFromUser:@"8001"
                                                          completion:^(NSString *aUsername, EMError *aError) {
                                                              if (!aError) {
                                                                  NSLog(@"同意好友成功");
                                                              }
                                                          }];

// 拒絕好友申請
[[EMClient sharedClient].contactManager declineFriendRequestFromUser:@"8001"
                                                          completion:^(NSString *aUsername, EMError *aError) {
                                                              if (!aError) {
                                                                  NSLog(@"拒絕好友成功");
                                                              }
                                                          }];

// 刪除好友
[[EMClient sharedClient].contactManager deleteContact:@"8001"
                                 isDeleteConversation: YES
                                           completion:^(NSString *aUsername, EMError *aError) {
                                               if (!aError) {
                                                   NSLog(@"刪除成功");
                                               }
                                           }];
    // 注冊好友dele <EMContactManagerDelegate>
    [[EMClient sharedClient].contactManager addDelegate:self delegateQueue:nil];
    // 移除dele
    [[EMClient sharedClient].contactManager removeDelegate:self];
    
    // 對方同意加好友請求后回調(diào)
    - (void)friendRequestDidApproveByUser:(NSString *)aUsername{}
    // 對方拒絕加好友請求后回調(diào)
    - (void)friendRequestDidDeclineByUser:(NSString *)aUsername{}
    // 對方刪除我膳帕,雙方都回調(diào)
    - (void)friendshipDidRemoveByUser:(NSString *)aUsername{}
    // 對方同意好友請求后粘捎,雙方回調(diào)
    - (void)friendshipDidAddByUser:(NSString *)aUsername{}
    // 對方發(fā)送好友請求后回調(diào)
    - (void)friendRequestDidReceiveFromUser:(NSString *)aUsername message:(NSString *)aMessage{}

    // 獲取好友黑名單
    EMError *error = nil;
    NSArray *blackList = [[EMClient sharedClient].contactManager getBlackListFromServerWithError:&error];
    if (!error) {
        NSLog(@"獲取成功 -- %@",blackList);
    }
    // 從數(shù)據(jù)庫獲取黑名單列表
    NSArray *blockList = [[EMClient sharedClient].contactManager getBlackList];
    
    
    // 加入黑名單
    EMError *error = [[EMClient sharedClient].contactManager addUserToBlackList:@"6001" relationshipBoth:YES];
    if (!error) {
        NSLog(@"發(fā)送成功");
    }
    
    // 移除黑名單
    EMError *error = [[EMClient sharedClient].contactManager removeUserFromBlackList:@"6001"];
    if (!error) {
        NSLog(@"發(fā)送成功");
    }

會話

獲取所有會話(內(nèi)存中有則從內(nèi)存中取,沒有則從db中取)
 NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];

獲取或創(chuàng)建會話
 EMConversation *conversation = [[EMClient sharedClient].chatManager getConversation:@"8001" type:EMConversationTypeChat createIfNotExist:YES];
     EMConversationTypeChat            單聊會話
     EMConversationTypeGroupChat       群聊會話
     EMConversationTypeChatRoom        聊天室會話
 
刪除會話
 [[EMClient sharedClient].chatManager deleteConversation:@"8001" isDeleteMessages:YES completion:^(NSString *aConversationId, EMError *aError){
 //code
 }];
 
根據(jù) conversationId 批量刪除會話
 EMConversation *conversation = [[EMClient sharedClient].chatManager getConversation:@"8001" type:EMConversationTypeChat createIfNotExist:NO];
 [[EMClient sharedClient].chatManager deleteConversations:@[conversation] isDeleteMessages:YES completion:^(EMError *aError){
 //code
 }];

獲取會話未讀消息數(shù)
 [EMConversation unreadMessagesCount];


獲取會話中的消息
    // 從數(shù)據(jù)庫獲取時間段內(nèi)的消息(時間單位:毫秒)危彩,最大數(shù)量10
    [conversion loadMessagesFrom:1000 to:1000 count:10 completion:^(NSArray *aMessages, EMError *aError) {
        // 獲取完畢后回調(diào)
    }];
    //  從數(shù)據(jù)庫獲取指定id的消息
    [conversion loadMessageWithId:@"messageId" error:nil];
    // 從數(shù)據(jù)庫獲取從指定id的消息(不包含)后開始10條消息
    [conversion loadMessagesStartFromId:@"messageId" count:10 searchDirection:EMMessageSearchDirectionUp completion:^(NSArray *aMessages, EMError *aError) {
    }];
    // 從數(shù)據(jù)庫獲取從指定時間(毫秒)指定發(fā)送人攒磨,從上到下10條消息
    [conversion loadMessagesWithType:EMMessageBodyTypeText timestamp:1000 count:10 fromUser:@"" searchDirection:EMMessageSearchDirectionUp completion:^(NSArray *aMessages, EMError *aError) {
    }];
    // 從數(shù)據(jù)庫獲取從指定時間(毫秒)指定發(fā)送人包含關(guān)鍵字,從上到下10條消息
    [conversion loadMessagesWithKeyword:@"keyWord" timestamp:1000 count:10 fromUser:@"" searchDirection:EMMessageSearchDirectionUp completion:^(NSArray *aMessages, EMError *aError) {
    }];

消息

1.消息體
文本消息
 EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:@"要發(fā)送的消息"];
圖片消息
 EMImageMessageBody *body = [[EMImageMessageBody alloc] initWithData:data displayName:@"image.png"];
位置消息
 EMLocationMessageBody *body = [[EMLocationMessageBody alloc] initWithLatitude:39 longitude:116 address:@"地址"];
語音消息
 EMVoiceMessageBody *body = [[EMVoiceMessageBody alloc] initWithLocalPath:@"audioPath" displayName:@"audio"];
 body.duration = duration;
視頻消息
 EMVideoMessageBody *body = [[EMVideoMessageBody alloc] initWithLocalPath:@"videoPath" displayName:@"video.mp4"];
文件消息
 EMFileMessageBody *body = [[EMFileMessageBody alloc] initWithLocalPath:@"filePath" displayName:@"file"];
透傳消息
 EMCmdMessageBody *body = [[EMCmdMessageBody alloc] initWithAction:action];
 2.消息
 // 消息
 NSString *from = [[EMClient sharedClient] currentUsername];
 EMMessage *message = [[EMMessage alloc] initWithConversationID:@"6001" from:from to:@"6001" body:body ext:messageExt];
 message.chatType = EMChatTypeChat;         // 單聊,EMChatTypeGroupChat群聊 EMChatTypeChatRoom聊天室
 message.ext = @{@"key":@"value"};          // 擴展消息
 
 3.插入消息
 [[EMClient sharedClient].chatManager importMessages:@[message] completion:^(EMError *aError) {
 //code
 }];

 3.發(fā)送消息(異步)
 [[EMClient sharedClient].chatManager sendMessage:[EMMessage new] progress:^(int progress) {
 } completion:^(EMMessage *message, EMError *error) {
 }];
 

 // 更新消息到 DB
 [[EMClient sharedClient].chatManager updateMessage:aMessage];
 // 添加dele   <EMChatManagerDelegate>
 [[EMClient sharedClient].chatManager addDelegate:self delegateQueue:nil];
 // 移除dele
 [[EMClient sharedClient].chatManager removeDelegate:self];


// 收到消息(非透傳)后回調(diào)
- (void)messagesDidReceive:(NSArray *)aMessages{
    
    //
    for (EMMessage *message in aMessages) {
        // 消息中的擴展屬性
        NSDictionary *ext = message.ext;
    
        
        EMMessageBody *msgBody = message.body;
        switch (msgBody.type) {
            case EMMessageBodyTypeText:{
                // 收到的文字消息
                EMTextMessageBody *textBody = (EMTextMessageBody *)msgBody;
                NSString *txt = textBody.text;
                NSLog(@"收到的文字是 txt -- %@",txt);
            }
                break;
            case EMMessageBodyTypeImage:{
                // 得到一個圖片消息body
                EMImageMessageBody *body = ((EMImageMessageBody *)msgBody);
                NSLog(@"大圖remote路徑 -- %@"   ,body.remotePath);
                NSLog(@"大圖local路徑 -- %@"    ,body.localPath); // // 需要使用sdk提供的下載方法后才會存在
                NSLog(@"大圖的secret -- %@"    ,body.secretKey);
                NSLog(@"大圖的W -- %f ,大圖的H -- %f",body.size.width,body.size.height);
                NSLog(@"大圖的下載狀態(tài) -- %lu",body.downloadStatus);
                
                
                // 縮略圖sdk會自動下載
                NSLog(@"小圖remote路徑 -- %@"   ,body.thumbnailRemotePath);
                NSLog(@"小圖local路徑 -- %@"    ,body.thumbnailLocalPath);
                NSLog(@"小圖的secret -- %@"    ,body.thumbnailSecretKey);
                NSLog(@"小圖的W -- %f ,大圖的H -- %f",body.thumbnailSize.width,body.thumbnailSize.height);
                NSLog(@"小圖的下載狀態(tài) -- %lu",body.thumbnailDownloadStatus);
            }
                break;
            case EMMessageBodyTypeLocation:{
                
                EMLocationMessageBody *body = (EMLocationMessageBody *)msgBody;
                NSLog(@"緯度-- %f",body.latitude);
                NSLog(@"經(jīng)度-- %f",body.longitude);
                NSLog(@"地址-- %@",body.address);
            }
                break;
            case EMMessageBodyTypeVoice:{
                
                // 音頻sdk會自動下載
                EMVoiceMessageBody *body = (EMVoiceMessageBody *)msgBody;
                NSLog(@"音頻remote路徑 -- %@"      ,body.remotePath);
                NSLog(@"音頻local路徑 -- %@"       ,body.localPath); // 需要使用sdk提供的下載方法后才會存在(音頻會自動調(diào)用)
                NSLog(@"音頻的secret -- %@"        ,body.secretKey);
                NSLog(@"音頻文件大小 -- %lld"       ,body.fileLength);
                NSLog(@"音頻文件的下載狀態(tài) -- %lu"   ,body.downloadStatus);
                NSLog(@"音頻的時間長度 -- %lu"      ,body.duration);
            }
                break;
            case EMMessageBodyTypeVideo:{
                
                EMVideoMessageBody *body = (EMVideoMessageBody *)msgBody;
                
                NSLog(@"視頻remote路徑 -- %@"      ,body.remotePath);
                NSLog(@"視頻local路徑 -- %@"       ,body.localPath); // 需要使用sdk提供的下載方法后才會存在
                NSLog(@"視頻的secret -- %@"        ,body.secretKey);
                NSLog(@"視頻文件大小 -- %lld"       ,body.fileLength);
                NSLog(@"視頻文件的下載狀態(tài) -- %lu"   ,body.downloadStatus);
                NSLog(@"視頻的時間長度 -- %lu"      ,body.duration);
                NSLog(@"視頻的W -- %f ,視頻的H -- %f", body.thumbnailSize.width, body.thumbnailSize.height);
                
                // 縮略圖sdk會自動下載
                NSLog(@"縮略圖的remote路徑 -- %@"     ,body.thumbnailRemotePath);
                NSLog(@"縮略圖的local路徑 -- %@"      ,body.thumbnailLocalPath);
                NSLog(@"縮略圖的secret -- %@"        ,body.thumbnailSecretKey);
                NSLog(@"縮略圖的下載狀態(tài) -- %lu"      ,body.thumbnailDownloadStatus);
            }
                break;
            case EMMessageBodyTypeFile:{
                
                EMFileMessageBody *body = (EMFileMessageBody *)msgBody;
                NSLog(@"文件remote路徑 -- %@"      ,body.remotePath);
                NSLog(@"文件local路徑 -- %@"       ,body.localPath); // 需要使用sdk提供的下載方法后才會存在
                NSLog(@"文件的secret -- %@"        ,body.secretKey);
                NSLog(@"文件文件大小 -- %lld"       ,body.fileLength);
                NSLog(@"文件文件的下載狀態(tài) -- %lu"   ,body.downloadStatus);
            }
                break;
                
            default:
                break;
        }
    }
}
// 收到透傳(cmd)在線消息后回調(diào)
- (void)cmdMessagesDidReceive:(NSArray *)aCmdMessages{
    for (EMMessage *message in aCmdMessages) {
        
        // cmd消息中的擴展屬性
        NSDictionary *ext = message.ext;
        
        
        EMCmdMessageBody *body = (EMCmdMessageBody *)message.body;
        NSLog(@"收到的action是 -- %@",body.action);
    }
}


// 會話列表變動后調(diào)用
- (void)conversationListDidUpdate:(NSArray *)aConversationList{}
// 收到消息后調(diào)用
- (void)messagesDidReceive:(NSArray *)aMessages{}
// 收到cmd透傳消息后調(diào)用
- (void)cmdMessagesDidReceive:(NSArray *)aCmdMessages{}
// 消息已讀后回調(diào)
- (void)messagesDidRead:(NSArray *)aMessages{}
// 消息送達后回調(diào)
- (void)messagesDidDeliver:(NSArray *)aMessages{}
// 消息撤回后回調(diào)
- (void)messagesDidRecall:(NSArray *)aMessages{}
// 消息狀態(tài)改變時調(diào)用
- (void)messageStatusDidChange:(EMMessage *)aMessage error:(EMError *)aError{}
// 消息附件狀態(tài)改變時調(diào)用
- (void)messageAttachmentStatusDidChange:(EMMessage *)aMessage error:(EMError *)aError{}

群組

群組類型(4種)
    EMGroupStylePrivateOnlyOwnerInvite 私有群組汤徽,創(chuàng)建完成后娩缰,只允許 Owner 邀請用戶加入
    EMGroupStylePrivateMemberCanInvite 私有群組,創(chuàng)建完成后谒府,只允許 Owner 和群成員邀請用戶加入
    EMGroupStylePublicJoinNeedApproval 公開群組拼坎,創(chuàng)建完成后,只允許 Owner 邀請用戶加入; 非群成員用戶需發(fā)送入群申請完疫,Owner 同意后才能入組
    EMGroupStylePublicOpenJoin         公開群組演痒,創(chuàng)建完成后,允許非群組成員加入趋惨,不需要管理員同意
創(chuàng)建群組
    EMError *error = nil;
    EMGroupOptions *setting = [[EMGroupOptions alloc] init];
    setting.maxUsersCount = 500;
    setting.style = EMGroupStylePublicOpenJoin;// 創(chuàng)建不同類型的群組鸟顺,這里需要才傳入不同的類型
    EMGroup *group = [[EMClient sharedClient].groupManager createGroupWithSubject:@"群組名稱" description:@"群組描述" invitees:@[@"6001",@"6002"] message:@"邀請您加入群組" setting:setting error:&error];
    if(!error){
        NSLog(@"創(chuàng)建成功 -- %@",group);
    }

獲取群詳情
    // 獲取群詳情
    EMGroup *group=[[EMClient sharedClient].groupManager getGroupSpecificationFromServerWithId:@"groupId" error:nil];
    // 獲取群詳情
    [[EMClient sharedClient].groupManager getGroupSpecificationFromServerWithId:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    
    // 申請加入群組
    EMError *error = nil;
    [[EMClient sharedClient].groupManager applyJoinPublicGroup:@"groupId" message:@"" error:nil];
    // 管理員 加人進群
    EMError *error = nil;
    [[EMClient sharedClient].groupManager addOccupants:@[@"user1"] toGroup:@"groupId" welcomeMessage:@"message" error:&error];
    // 管理員 同意進群申請
    EMError *error = [[EMClient sharedClient].groupManager acceptJoinApplication:@"groupId" applicant:@"user1"];
    // 管理員 拒絕加群申請
    EMError *error = [[EMClient sharedClient].groupManager declineJoinApplication:@"groupId" groupname:@"subject" applicant:@"user1" reason:@"拒絕的原因"];
    
    // 加入公開群
    MError *error = nil;
    [[EMClient sharedClient].groupManager joinPublicGroup:@"1410329312753" error:&error];
    
    // 主動退群
    EMError *error = nil;
    [[EMClient sharedClient].groupManager leaveGroup:@"1410329312753" error:&error];
    
    // 解散群組
    EMError *error = nil;
    [[EMClient sharedClient].groupManager destroyGroup:@"groupId" error:&error];
    if (!error) {
        NSLog(@"解散成功");
    }
    
    // 修改群名稱
    EMError *error = nil;
    [[EMClient sharedClient].groupManager changeGroupSubject:@"要修改的名稱" forGroup:@"1410329312753" error:&error];
    if (!error) {
        NSLog(@"修改成功");
    }
    // 修改群描述
    EMError *error = nil;
    EMGroup* group = [[EMClient sharedClient].groupManager changeDescription:@"修改的群描述" forGroup:@"1410329312753" error:&error];
    if (!error) {
        NSLog(@"修改成功");
    }
    
    // 獲取群成員列表
    EMError *error = nil;
    EMCursorResult* result = [[EMClient sharedClient].groupManager getGroupMemberListFromServerWithId:@"groupId" cursor:@"cursor" pageSize:50 error:&error];
    if (!error) {
        NSLog(@"獲取成功");
        // result.list: 返回的成員列表,內(nèi)部的值是成員的環(huán)信id器虾。
        // result.cursor: 返回的cursor讯嫂,如果要取下一頁的列表,需要將這個cursor當(dāng)參數(shù)傳入到獲取群組成員列表中兆沙。
    }
    // 異步 
    [[EMClient sharedClient].groupManager getGroupMemberListFromServerWithId:@"" cursor:@"" pageSize:50 completion:^(EMCursorResult *aResult, EMError *aError) {
    }];
    
    // 獲取群黑名單列表
    EMError *error = nil;
    EMGroup* group = [[EMClient sharedClient].groupManager getGroupBlacklistFromServerWithId:@"groupId" pageNumber:1 pageSize:50 error:&error];
    if (!error) {
        NSLog(@"獲取成功");
    }
    // 異步
    [[EMClient sharedClient].groupManager getGroupBlacklistFromServerWithId:@"" pageNumber:@1 pageSize:@50 completion:^(NSArray *aList, EMError *aError) {
    }];

    // 獲取被禁言列表
    EMError *error = nil;
    EMGroup* group = [[EMClient sharedClient].groupManager getGroupMuteListFromServerWithId:@"groupId" pageNumber:1 pageSize:50 error:&error];
    if (!error) {
        NSLog(@"獲取成功");
    }
    // 異步
    [[EMClient sharedClient].groupManager getGroupMuteListFromServerWithId:@"" pageNumber:1 pageSize:50 completion:^(NSArray *aList, EMError *aError) {
}];
    
    // 獲取群公告
    [[EMClient sharedClient].groupManager getGroupAnnouncementWithId:@"groupId"
                                                          completion:^(NSString *aAnnouncement, EMError *aError) {
                                                              if (!aError) {
                                                                  NSLog(@"獲取成功");
                                                              }
                                                          }];
    // 異步
    [[EMClient sharedClient].groupManager updateGroupAnnouncementWithId:@"" announcement:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    
    // 修改群公告
    [[EMClient sharedClient].groupManager updateGroupAnnouncementWithId:@"groupid"
                                                           announcement:@"群公告"
                                                             completion:^(EMGroup *aGroup, EMError *aError) {
                                                                 if (!aError) {
                                                                     NSLog(@"修改成功");
                                                                 }
                                                             }];
    
    
    // 獲取群共享文件列表
    // 同步
    NSArray *arr=[[EMClient sharedClient].groupManager getGroupFileListWithId:@"" pageNumber:1 pageSize:10 error:nil];
    // 異步
    [[EMClient sharedClient].groupManager getGroupFileListWithId:@"groupId"
                                                      pageNumber:1
                                                        pageSize:10
                                                      completion:^(NSArray *aList, EMError *aError) {
                                                          if (!aError) {
                                                              NSLog(@"獲取成功");
                                                          }
                                                      }];
    
    // 上傳群文件
    [[EMClient sharedClient].groupManager uploadGroupSharedFileWithId:@"groupId"
                                                             filePath:@"filePath"
                                                             progress:^(int progress){
                                                             } completion:^(EMGroupSharedFile *aSharedFile, EMError *aError) {
                                                                 if (!aError) {
                                                                     NSLog(@"上傳成功");
                                                                 }
                                                             }];
    // 下載群文件
    [[EMClient sharedClient].groupManager downloadGroupSharedFileWithId:@"groupId"
                                                               filePath:@"filePath"
                                                           sharedFileId:@"fileId"
                                                               progress:^(int progress) {
                                                               } completion:^(EMGroup *aGroup, EMError *aError) {
                                                                   if (!aError) {
                                                                       NSLog(@"下載成功");
                                                                   }
                                                               }];
    // 刪除共享文件 同步
    EMError *error = nil;
    [[EMClient sharedClient].groupManager removeGroupSharedFileWithId:@"groupId" sharedFileId:@"fileId" error:&error];
    if (!error) {
        NSLog(@"刪除成功");
    }
     // 異步
    [[EMClient sharedClient].groupManager removeGroupSharedFileWithId:@"" sharedFileId:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    
    // 修改群擴展信息(同步/異步)
    [[EMClient sharedClient].groupManager updateGroupExtWithId:@"" ext:@"" error:nil];
    [[EMClient sharedClient].groupManager updateGroupExtWithId:@"groupId"
                                                           ext:@"ext"
                                                    completion:^(EMGroup *aGroup, EMError *aError) {
                                                        if (!aError) {
                                                            NSLog(@"修改成功");
                                                        }
                                                    }];
    

    // 改變?nèi)褐鳎ū仨毷侨褐鳎?    EMError *error = nil;
    [[EMClient sharedClient].groupManager updateGroupOwner:@"groupId" newOwner:@"newOwner" error:&error];
    // 改變?nèi)褐鳎ó惒剑?    [[EMClient sharedClient].groupManager updateGroupOwner:@"" newOwner:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 添加群管理員
    EMError *error = nil;
    [[EMClient sharedClient].groupManager addAdmin:@"adminName" toGroup:@"groupId" error:&error];
    [[EMClient sharedClient].groupManager addAdmin:@"" toGroup:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 移除群管理員
    EMError *error = nil;
    [[EMClient sharedClient].groupManager removeAdmin:@"adminName" fromGroup:@"groupId" error:&error];
    [[EMClient sharedClient].groupManager removeAdmin:@"" fromGroup:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 移除群成員
    EMError *error = nil;
    [[EMClient sharedClient].groupManager removeOccupants:@[@"user1"] fromGroup:@"1410329312753" error:&error];
    [[EMClient sharedClient].groupManager removeMembers:@[] fromGroup:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 禁言群成員
    EMError *error = nil;
    [[EMClient sharedClient].groupManager muteMembers:@[userName] muteMilliseconds:-1 fromGroup:@"groupId" error:&error];
    [[EMClient sharedClient].groupManager muteMembers:@"" muteMilliseconds:30 fromGroup:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 解禁言群成員
    EMError *error = nil;
    [[EMClient sharedClient].groupManager unmuteMembers:@[userName] fromGroup:@"groupId" error:&error];
    [[EMClient sharedClient].groupManager unmuteMembers:@[] fromGroup:@"" completion:^(EMGroup *aGroup, EMError *aError) {
    }];
    // 加入群黑名單
    EMError *error = nil;
    EMGroup *group = [[EMClient sharedClient].groupManager blockOccupants:@[@"user1"] fromGroup:@"1410329312753" error:&error];
    // 移除群黑名單
    EMError *error = nil;
    EMGroup *group = [[EMClient sharedClient].groupManager unblockOccupants:@[@"user1"] forGroup:@"1410329312753" error:&error];
    
    
    // 屏蔽/取消屏蔽 群消息
    [[EMClient sharedClient].groupManager blockGroup:@"groupId" error:nil];
    [[EMClient sharedClient].groupManager unblockGroup:@"groupId" error:nil];
    
    
    // 內(nèi)存中獲取所有群組欧芽,第一次從數(shù)據(jù)庫加載
    NSArray *groupList = [[EMClient sharedClient].groupManager getJoinedGroups];
    // 獲取和登錄者相關(guān)的群組
    EMError *error = nil;
    NSArray *myGroups = [[EMClient sharedClient].groupManager getJoinedGroupsFromServerWithPage:1 pageSize:50 error:&error];
    if (!error) {
        NSLog(@"獲取成功 -- %@",myGroups);
    }
    // 獲取公開群組
    EMError *error = nil;
    EMCursorResult *result = [[EMClient sharedClient].groupManager getPublicGroupsFromServerWithCursor:nil pageSize:50 error:&error];
    if (!error) {
        NSLog(@"獲取成功 -- %@",result);
    }
    // 群組dele <EMGroupManagerDelegate>
    [[EMClient sharedClient].groupManager addDelegate:self delegateQueue:nil];
    // 移除群組dele
    [[EMClient sharedClient].groupManager removeDelegate:self];

    // 對方邀請我加入某群時調(diào)用
    - (void)groupInvitationDidReceive:(NSString *)aGroupId inviter:(NSString *)aInviter message:(NSString *)aMessage{}
    // 對方同意我的加群邀請時調(diào)用
    - (void)groupInvitationDidAccept:(EMGroup *)aGroup invitee:(NSString *)aInvitee{}
    // 對方拒絕我的加群邀請時調(diào)用
    - (void)groupInvitationDidDecline:(EMGroup *)aGroup invitee:(NSString *)aInvitee reason:(NSString *)aReason{}
    // 自動加入群后回調(diào)(對方邀請)(EMOptions的isAutoAcceptGroupInvitation為YES)
    - (void)didJoinGroup:(EMGroup *)aGroup inviter:(NSString *)aInviter message:(NSString *)aMessage{}
    // 離開群組后回調(diào)
    - (void)didLeaveGroup:(EMGroup *)aGroup reason:(EMGroupLeaveReason)aReason{}
    // 收到入群請求后回調(diào)(群的類型是EMGroupStylePublicJoinNeedApproval)
    - (void)joinGroupRequestDidReceive:(EMGroup *)aGroup user:(NSString *)aUsername reason:(NSString *)aReason{}
    // 申請入群被拒后回調(diào)(群的類型是EMGroupStylePublicJoinNeedApproval)
    - (void)joinGroupRequestDidDecline:(NSString *)aGroupId reason:(NSString *)aReason{}
    // 申請入群被同意后回調(diào)(群的類型是EMGroupStylePublicJoinNeedApproval)
    - (void)joinGroupRequestDidApprove:(EMGroup *)aGroup{}
    // 群組列表更新后回調(diào)
    - (void)groupListDidUpdate:(NSArray *)aGroupList{}
    // 有成員被加入禁言列表后調(diào)用
    - (void)groupMuteListDidUpdate:(EMGroup *)aGroup addedMutedMembers:(NSArray *)aMutedMembers muteExpire:(NSInteger)aMuteExpire{}
    // 有成員被移除禁言列表后調(diào)用
    - (void)groupMuteListDidUpdate:(EMGroup *)aGroup removedMutedMembers:(NSArray *)aMutedMembers{}
    // 有成員被加入管理員列表后調(diào)用
    - (void)groupAdminListDidUpdate:(EMGroup *)aGroup addedAdmin:(NSString *)aAdmin{}
    // 有成員被移除管理員列表后調(diào)用
    - (void)groupAdminListDidUpdate:(EMGroup *)aGroup removedAdmin:(NSString *)aAdmin{}
    // 群組創(chuàng)建者更新后回調(diào)
    - (void)groupOwnerDidUpdate:(EMGroup *)aGroup newOwner:(NSString *)aNewOwner oldOwner:(NSString *)aOldOwner{}
    // 有用戶加入群組后回調(diào)
    - (void)userDidJoinGroup:(EMGroup *)aGroup user:(NSString *)aUsername{}
    // 有用戶離開群組后調(diào)用
    - (void)userDidLeaveGroup:(EMGroup *)aGroup user:(NSString *)aUsername{}
    // 群公告更新后調(diào)用
    - (void)groupAnnouncementDidUpdate:(EMGroup *)aGroup announcement:(NSString *)aAnnouncement{}
    // 有用戶上傳文件后調(diào)用
    - (void)groupFileListDidUpdate:(EMGroup *)aGroup addedSharedFile:(EMGroupSharedFile *)aSharedFile{}
    // 有用戶刪除群共享文件
    - (void)groupFileListDidUpdate:(EMGroup *)aGroup removedSharedFile:(NSString *)aFileId{}

群主
// 作為群主 收到入群申請時調(diào)用
- (void)didReceiveJoinGroupApplication:(EMGroup *)aGroup applicant:(NSString *)aApplicant reason:(NSString *)aReason{}

聊天頁面

進入系統(tǒng)單聊頁面
 EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"8001" conversationType:EMConversationTypeChat];

進入系統(tǒng)群聊頁面
 EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"groupId" conversationType:EMConversationTypeGroupChat];
    // 下載消息中的附件
    [[EMClient sharedClient].chatManager downloadMessageThumbnail:message progress:^(int progress) {
    } completion:^(EMMessage *message, EMError *error) {
    }];
    // 下載消息中的原始附件
    [[EMClient sharedClient].chatManager downloadMessageAttachment:message progress:^(int progress) {
    } completion:^(EMMessage *message, EMError *error) {
    }];
    
    // 發(fā)送已讀回執(zhí)(需要開發(fā)者手動調(diào)用)
    [[EMClient sharedClient].chatManager sendMessageReadAck:message completion:^(EMMessage *aMessage, EMError *aError) {
        if(!aError){
            NSLog(@"send success");
        }
    }];
    
    // 獲取消息漫游
    [[EMClient sharedClient].chatManager fetchHistoryMessagesFromServer:@"要獲取漫游消息的Conversation id" conversationType:EMConversationTypeChat startMessageId:@"參考起始消息的ID" pageSize:10 error:nil];
    // 獲取消息漫游(異步)
    [[EMClient sharedClient].chatManager asyncFetchHistoryMessagesFromServer:@"" conversationType:EMConversationTypeChat startMessageId:@"" pageSize:10 complation:^(EMCursorResult *aResult, EMError *aError) {
    }];
    // 撤回消息
    [[EMClient sharedClient].chatManager recallMessage:message completion:^(EMMessage *aMessage, EMError *aError) {
    }];

聊天室

   // 獲取聊天室
    EMError *error = nil;
    NSArray *list = [[EMClient sharedClient].roomManager getChatroomsFromServerWithPage:0 pageSize:50 error:&error];
    [[EMClient sharedClient].roomManager getChatroomsFromServerWithPage:0 pageSize:10 completion:^(EMPageResult *aResult, EMError *aError) {
    }];
    // 加入聊天室
    EMError *error = nil;
    EMChatroom *chatroom = [[EMClient sharedClient].roomManager joinChatroom:@"chatroomId" error:&error];
    [[EMClient sharedClient].roomManager joinChatroom:@"" completion:^(EMChatroom *aChatroom, EMError *aError) {
    }];
    // 移除聊天室
    EMError *error = nil;
    [[EMClient sharedClient].roomManager leaveChatroom:@"chatroomId" error:&error];
    [[EMClient sharedClient].roomManager leaveChatroom:@"" completion:^(EMError *aError) {
}];
    // 獲取聊天室詳情
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager getChatroomSpecificationFromServerWithId:@"roomId"error:&error];
    [[EMClient sharedClient].roomManager getChatroomSpecificationFromServerWithId:@"" completion:^(EMChatroom *aChatroom, EMError *aError) {
    }];
    // 獲取聊天室成員列表
    EMError *error = nil;
    EMCursorResult *result = [[EMClient sharedClient].roomManager getChatroomMemberListFromServerWithId:@"roomId" cursor:@"cursor" pageSize:50 error:&error];
    [[EMClient sharedClient].roomManager getChatroomMemberListFromServerWithId:@"" cursor:@"" pageSize:10 completion:^(EMCursorResult *aResult, EMError *aError) {
 }];
    // 獲取聊天室黑名單
    EMError *error = nil;
    NSArray *list = [[EMClient sharedClient].roomManager getChatroomBlacklistFromServerWithId:@"roomId" pageNumber:1 pageSize:50 error:&error];
    [[EMClient sharedClient].roomManager getChatroomBlacklistFromServerWithId:@"" pageNumber:0 pageSize:10 completion:^(NSArray *aList, EMError *aError) {
    }];
    // 獲取聊天室禁言列表
    EMError *error = nil;
    NSArray *list = [[EMClient sharedClient].roomManager getChatroomMuteListFromServerWithId:@"roomId" pageNumber:1 pageSize:50 error:&error];
    [[EMClient sharedClient].roomManager getChatroomMuteListFromServerWithId:@"" pageNumber:0 pageSize:10 completion:^(NSArray *aList, EMError *aError) {
    }];
    // 更新聊天室名稱
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager updateSubject:@"newSubject" forChatroom:@"roomId" error:&error];
    [[EMClient sharedClient].roomManager updateSubject:@"" forChatroom:@"" completion:^(EMChatroom *aChatroom, EMError *aError) {
    }];
    // 更新聊天室說明
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager updateDescription:@"newDes" forChatroom:@"roomId" error:&error];
    [[EMClient sharedClient].roomManager getChatroomAnnouncementWithId:@"" completion:^(NSString *aAnnouncement, EMError *aError) {
    }];
    // 獲取聊天室公告
    NSString *content=[[EMClient sharedClient].roomManager getChatroomAnnouncementWithId:@"" error:nil];
    [[EMClient sharedClient].roomManager getChatroomAnnouncementWithId:@"chatroomId"
                                                            completion:^(NSString *aAnnouncement, EMError *aError) {
                                                                if (!aError) {
                                                                    NSLog(@"獲取成功");
                                                                }
                                                            }];
    // 更新聊天室公告
    EMChatroom *room=[[EMClient sharedClient].roomManager updateChatroomAnnouncementWithId:@"" announcement:@"" error:nil];
    [[EMClient sharedClient].roomManager updateChatroomAnnouncementWithId:@"chatroomId"
                                                             announcement:@"announcement"
                                                               completion:^(EMChatroom *aChatroom, EMError *aError) {
                                                                   if (!aError) {
                                                                       NSLog(@"修改成功");
                                                                   }
                                                               }];
    
    // 以下相關(guān)方法都有同步異步執(zhí)行,就省略了

    // 將某成員移除聊天室
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager removeMembers:@[@"username"] fromChatroom:@"roomId" error:&error];
    // 將某成員加入黑名單
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager blockMembers:@[@"username"] fromChatroom:@"roomId" error:&error];
    // 將某成員移除黑名單
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager unblockMembers:@[@"username"] fromChatroom:@"roomId" error:&error];
    // 改變聊天室創(chuàng)建者時調(diào)用
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager updateChatroomOwner:@"roomId" newOwner:@"newOwner" error:&error];
    // 添加聊天室管理員
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager addAdmin:@"adminName" toChatroom:@"roomId" error:&error];
    // 移除聊天室管理員
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager removeAdmin:@"adminName" fromChatroom:@"roomId" error:&error];
    
    // 禁言聊天室成員
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager muteMembers:@[@"userName"] muteMilliseconds:100 aChatroomId:@"roomId" error:&error];
    
    // 解禁言聊天室成員
    EMError *error = nil;
    EMChatroom *room = [[EMClient sharedClient].roomManager unmuteMembers:@[@"userName"] fromChatroom:@"roomId" error:&error];
    // 添加dele <EMChatroomManagerDelegate>
    [[EMClient sharedClient].roomManager addDelegate:self delegateQueue:nil];
    // 移除dele
    [[EMClient sharedClient].roomManager removeDelegate:self];
    
    // 有用戶加入聊天室后調(diào)用
    - (void)userDidJoinChatroom:(EMChatroom *)aChatroom user:(NSString *)aUsername{}
    // 有用戶離開聊天室后調(diào)用
    - (void)userDidLeaveChatroom:(EMChatroom *)aChatroom user:(NSString *)aUsername{}
    // 被踢出聊天室后調(diào)用
    - (void)didDismissFromChatroom:(EMChatroom *)aChatroom reason:(EMChatroomBeKickedReason)aReason{}
    // 有成員被禁言時調(diào)用
    - (void)chatroomMuteListDidUpdate:(EMChatroom *)aChatroom addedMutedMembers:(NSArray *)aMutes muteExpire:(NSInteger)aMuteExpire{}
    // 有成員被移除禁言列表時調(diào)用
    - (void)chatroomMuteListDidUpdate:(EMChatroom *)aChatroom removedMutedMembers:(NSArray *)aMutes{}
    // 有成員被加入管理員列表時調(diào)用
    - (void)chatroomAdminListDidUpdate:(EMChatroom *)aChatroom addedAdmin:(NSString *)aAdmin
    // 有成員被移出管理員列表時調(diào)用
    - (void)chatroomAdminListDidUpdate:(EMChatroom *)aChatroom removedAdmin:(NSString *)aAdmin
    // 聊天室創(chuàng)建者更新時調(diào)用
    - (void)chatroomOwnerDidUpdate:(EMChatroom *)aChatroom newOwner:(NSString *)aNewOwner oldOwner:(NSString *)aOldOwner{}
    // 聊天室公告有更新時調(diào)用
    - (void)chatroomAnnouncementDidUpdate:(EMChatroom *)aChatroom announcement:(NSString *)aAnnouncement{}

通話

    // 1.option配置
    EMCallOptions *options = [[EMClient sharedClient].callManager getCallOptions];
    // 當(dāng)對方不在線時葛圃,是否給對方發(fā)送離線消息和推送千扔,并等待對方回應(yīng)
    options.isSendPushIfOffline = NO;
    // 設(shè)置視頻分辨率:自適應(yīng)分辨率、352 * 288库正、640 * 480曲楚、1280 * 720
    options.videoResolution = EMCallVideoResolutionAdaptive;
    // 最大視頻碼率,范圍 50 < videoKbps < 5000, 默認0, 0為自適應(yīng)褥符,建議設(shè)置為0
    options.maxVideoKbps = 0;
    // 最小視頻碼率
    options.minVideoKbps = 0;
    // 是否固定視頻分辨率龙誊,默認為NO
    options.isFixedVideoResolution = NO;
    [[EMClient sharedClient].callManager setCallOptions:options];
    // 2.發(fā)起通話
    [[EMClient sharedClient].callManager startCall:EMCallTypeVideo remoteName:@"被呼叫的用戶" ext:nil completion:^(EMCallSession *aCallSession, EMError *aError) {
        if(!aError){
        }
    }];
    // 2.同意通話
    EMError *error = nil;
    error = [[EMClient sharedClient].callManager answerIncomingCall:@"sessionId"];
    // 3.結(jié)束通話
    [[EMClient sharedClient].callManager endCall:@"sessionId" reason:EMCallEndReasonHangup];
    /
     EMCallEndReasonHangup   = 0,   對方掛斷
    EMCallEndReasonNoResponse,      對方?jīng)]有響應(yīng)
    EMCallEndReasonDecline,         對方拒接
    EMCallEndReasonBusy,            對方占線
    EMCallEndReasonFailed,          失敗
    EMCallEndReasonUnsupported,     功能不支持
    EMCallEndReasonRemoteOffline,   對方不在線
     /
    
    //
    EMCallSession *callSession=[EMCallSession new];
    // 本地視頻
    callSession.localVideoView = [[EMCallLocalView alloc] initWithFrame:CGRectMake(0,0,0,0)];
    [self.view addSubview:callSession.localVideoView];
    // 對方視頻
    callSession.remoteVideoView = [[EMCallRemoteView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    // 縮放Mode
    callSession.remoteVideoView.scaleMode = EMCallViewScaleModeAspectFill;
    [self.view addSubview:_callSession.remoteVideoView];
    
     // 暫停語音數(shù)據(jù)傳輸
    [callSession pauseVideo];
    // 恢復(fù)語音數(shù)據(jù)傳輸
    [callSession resumeVideo];
    // 暫停視圖數(shù)據(jù)傳輸
    [callSession pauseVideo];
    // 恢復(fù)視頻數(shù)據(jù)傳輸
    [callSession resumeVideo];
    // 是否使用前置攝像頭,false:后置
    [callSession switchCameraPosition:true];
    // 添加dele  <EMCallManagerDelegate>
    [[EMClient sharedClient].callManager addDelegate:self delegateQueue:nil];
    // 移除dele
    [[EMClient sharedClient]removeDelegate:self];
    // 收到視頻請求后調(diào)用
    - (void)callDidReceive:(EMCallSession *)aSession
    // 統(tǒng)一通話后雙方都回調(diào)
    - (void)callDidConnect:(EMCallSession *)aSession
    // 對方同意通話后回調(diào)
    - (void)callDidAccept:(EMCallSession *)aSession
    // 通話結(jié)束(包括出現(xiàn)錯誤)雙方都回調(diào)
    - (void)callDidEnd:(EMCallSession *)aSession reason:(EMCallEndReason)aReason error:(EMError *)aError{}
    // 對方中斷或者繼續(xù)數(shù)據(jù)流傳輸時調(diào)用
    - (void)callStateDidChange:(EMCallSession *)aSession type:(EMCallStreamingStatus)aType{}
    // 網(wǎng)絡(luò)狀態(tài)不穩(wěn)定時調(diào)用
    - (void)callNetworkDidChange:(EMCallSession *)aSession status:(EMCallNetworkStatus)aStatus{}

    // 離線dele <EMCallBuilderDelegate>
    [[EMClient sharedClient].callManager setBuilderDelegate:self];
    - (void)callRemoteOffline:(NSString *)aRemoteName{
        
        //
        NSString *text = [[EMClient sharedClient].callManager getCallOptions].offlineMessageText;
        EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:text];
        NSString *fromStr = [EMClient sharedClient].currentUsername;
        EMMessage *message = [[EMMessage alloc] initWithConversationID:aRemoteName from:fromStr to:aRemoteName body:body ext:@{@"em_apns_ext":@{@"em_push_title":text}}];
        message.chatType = EMChatTypeChat;
        
        [[EMClient sharedClient].chatManager sendMessage:message progress:nil completion:nil];
    }

多設(shè)備

    // 獲取當(dāng)前帳號在其他設(shè)備上的ID列表
    NSArray *otherPlatformIds = [[EMClient sharedClient].contactManager getSelfIdsOnOtherPlatformWithError:nil];
    if ([otherPlatformIds count] > 0) {
        NSString *chatter = otherPlatformIds[0];
        //獲取會話
        EMConversation *conversation = [[EMClient sharedClient].chatManager getConversation:chatter type:EMConversationTypeChat createIfNotExist:YES];
        
        //發(fā)送消息
        NSString *sendText = @"test";
        EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:sendText];
        NSString *from = [[EMClient sharedClient] currentUsername];
        EMMessage *message = [[EMMessage alloc] initWithConversationID:conversation.conversationId from:from to:chatter body:body ext:nil];
        message.chatType = EMChatTypeChat;
        [[EMClient sharedClient].chatManager sendMessage:message progress:nil completion:nil];
    }
    
    
    // <EMMultiDevicesDelegate>
    [[EMClient sharedClient] addMultiDevicesDelegate:self delegateQueue:nil];
    // 多設(shè)備收到好友時調(diào)用
    - (void)multiDevicesContactEventDidReceive:(EMMultiDevicesEvent)aEvent
username:(NSString *)aTarget
ext:(NSString *)aExt{
        NSString *message = [NSString stringWithFormat:@"%li-%@-%@", (long)aEvent, aTarget, aExt];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"alert.multi.contact", @"Contact Multi-devices") message:message delegate:self cancelButtonTitle:NSLocalizedString(@"ok", @"OK") otherButtonTitles:nil, nil];
        [alertView show];
    }
    // 多設(shè)備收到群組時調(diào)用
    - (void)multiDevicesGroupEventDidReceive:(EMMultiDevicesEvent)aEvent
groupId:(NSString *)aGroupId
ext:(id)aExt{
        NSString *message = [NSString stringWithFormat:@"%li-%@-%@", (long)aEvent, aGroupId, aExt];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"alert.multi.group", @"Group Multi-devices") message:message delegate:self cancelButtonTitle:NSLocalizedString(@"ok", @"OK") otherButtonTitles:nil, nil];
        [alertView show];
    }

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市喷楣,隨后出現(xiàn)的幾起案子趟大,更是在濱河造成了極大的恐慌鹤树,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,544評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件逊朽,死亡現(xiàn)場離奇詭異罕伯,居然都是意外死亡,警方通過查閱死者的電腦和手機叽讳,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,430評論 3 392
  • 文/潘曉璐 我一進店門追他,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人绽榛,你說我怎么就攤上這事湿酸。” “怎么了灭美?”我有些...
    開封第一講書人閱讀 162,764評論 0 353
  • 文/不壞的土叔 我叫張陵推溃,是天一觀的道長。 經(jīng)常有香客問我届腐,道長铁坎,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,193評論 1 292
  • 正文 為了忘掉前任犁苏,我火速辦了婚禮硬萍,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘围详。我一直安慰自己朴乖,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,216評論 6 388
  • 文/花漫 我一把揭開白布助赞。 她就那樣靜靜地躺著买羞,像睡著了一般。 火紅的嫁衣襯著肌膚如雪雹食。 梳的紋絲不亂的頭發(fā)上畜普,一...
    開封第一講書人閱讀 51,182評論 1 299
  • 那天,我揣著相機與錄音群叶,去河邊找鬼吃挑。 笑死,一個胖子當(dāng)著我的面吹牛街立,可吹牛的內(nèi)容都是我干的舶衬。 我是一名探鬼主播,決...
    沈念sama閱讀 40,063評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼几晤,長吁一口氣:“原來是場噩夢啊……” “哼约炎!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起蟹瘾,我...
    開封第一講書人閱讀 38,917評論 0 274
  • 序言:老撾萬榮一對情侶失蹤圾浅,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后憾朴,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體狸捕,經(jīng)...
    沈念sama閱讀 45,329評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,543評論 2 332
  • 正文 我和宋清朗相戀三年众雷,在試婚紗的時候發(fā)現(xiàn)自己被綠了灸拍。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片嚷那。...
    茶點故事閱讀 39,722評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡击碗,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出戈锻,到底是詐尸還是另有隱情编兄,我是刑警寧澤轩性,帶...
    沈念sama閱讀 35,425評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站狠鸳,受9級特大地震影響揣苏,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜件舵,卻給世界環(huán)境...
    茶點故事閱讀 41,019評論 3 326
  • 文/蒙蒙 一卸察、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧铅祸,春花似錦坑质、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,671評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至夜焦,卻和暖如春壳澳,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背茫经。 一陣腳步聲響...
    開封第一講書人閱讀 32,825評論 1 269
  • 我被黑心中介騙來泰國打工巷波, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人卸伞。 一個月前我還...
    沈念sama閱讀 47,729評論 2 368
  • 正文 我出身青樓抹镊,卻偏偏與公主長得像,于是被迫代替她去往敵國和親荤傲。 傳聞我的和親對象是個殘疾皇子垮耳,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,614評論 2 353

推薦閱讀更多精彩內(nèi)容

  • 點擊查看原文 Web SDK 開發(fā)手冊 SDK 概述 網(wǎng)易云信 SDK 為 Web 應(yīng)用提供一個完善的 IM 系統(tǒng)...
    layjoy閱讀 13,758評論 0 15
  • 1)項目里面不需要環(huán)信SDK的太多功能,只是想要聊天和好友功能,其他都不用终佛,那SDK一定要總是跟著更新么俊嗽? a.環(huán)...
    DefaultYuan閱讀 26,558評論 17 59
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件铃彰、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 12,094評論 4 62
  • android中如何顯示開發(fā)者服務(wù)器上的昵稱和頭像 http://www.imgeek.org/article/8...
    苦可樂閱讀 1,220評論 0 1
  • 來源于: Mr.pengge 圖像繪制總結(jié)
    huixiansheng閱讀 88評論 0 0