其中有一個(gè)擴(kuò)張消息類(lèi)的方法:
+ (EMMessage *)sendTextMessage:(NSString *)text
to:(NSString *)toUser
messageType:(EMChatType)messageType
messageExt:(NSDictionary *)messageExt;
在該方法中將你要賦予的用戶(hù)頭像和昵稱(chēng)進(jìn)行賦值。(這里可以用登錄時(shí)拿到的用戶(hù)頭像和昵稱(chēng))
如下:
+ (EMMessage *)sendTextMessage:(NSString *)text
to:(NSString *)toUser
messageType:(EMChatType)messageType
messageExt:(NSDictionary *)messageExt
{
NSString *willSendText = [EaseConvertToCommonEmoticonsHelper convertToCommonEmoticons:text];
EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:willSendText];
NSString *from = [[EMClient sharedClient] currentUsername];
//開(kāi)始 設(shè)置 擴(kuò)展類(lèi)消息
NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
[dic setValue:userDic[@"username"] forKey:@"username"];
[dic setValue:userDic[@"userHeadImg"] forKey:@"userHeadImg"];
[dic setValue:userDic[@"userid"] forKey:@"userid"];
[dic setValue:userDic[@"phonenum"] forKey:@"phonenum"];
for (NSString *key in messageExt.allKeys) {
[dic setValue:messageExt[key] forKey:key];
}
EMMessage *message = [[EMMessage alloc] initWithConversationID:toUser from:from to:toUser body:body ext:[dic copy]];
// 結(jié)束
// EMMessage *message = [[EMMessage alloc] initWithConversationID:toUser from:from to:toUser body:body ext:messageExt];
message.chatType = messageType;
return message;
}
除此方法外: 發(fā)送語(yǔ)音救湖、位置脏嚷、圖片的擴(kuò)展消息中也需設(shè)置頭像和昵稱(chēng)荠藤。