#pragma mark - 建群
- (_Bool)CreateGroup:(id)arg1 withMemberList:(id)arg2;
#pragma mark - 拉群
CGroupMgr类
- (_Bool)AddGroupMember:(id)arg1 withMemberList:(id)arg2 withDesp:(id)arg3;
#pragma mark - 获取好友列表
idcontactMgr = [[%c(MMServiceCenter) defaultCenter] getService:[%c(CContactMgr) class]];
NSMutableArray *contactList = [contactMgr getContactList:1contactType:0];//这里的type为1获取到全部好友,为2不全
#pragma mark - 根据userName在CContactMgr中获取联系人对象
idcontactMgr = [[%c(MMServiceCenter) defaultCenter] getService:[%c(CContactMgr) class]];
iduserContact = [contactMgr getContactByName:@""];或
iduserContact = [[[%c(MMServiceCenter) defaultCenter] getService:[%c(CContactMgr) class]] getContactByName:[rcd objectForKey:@"userName"]];
//获取除了自己的微信好友数组 为CContact对象
idcontactMgr = [[%c(MMServiceCenter) defaultCenter] getService:[%c(CContactMgr) class]];
NSMutableArray *contactList = [contactMgr getContactList:2contactType:0];
idDC = [%c(MMServiceCenter) defaultCenter];
CContactMgr *contactManager = [DC getService:[%c(CContactMgr) class]];
idselfContact = [contactManager getSelfContact];//CContact类继承于CBaseContact
NSMutableArray *realContactList = [NSMutableArray new];
//便利联系人 获取剔除自己后的数组
for(CContact *contactincontactList) {
if([contact isNormalFriendContact] && ![[contact getContactDisplayUsrName] isEqualToString:[selfContact getContactDisplayUsrName]]){
[realContactList addObject:contact];
}
}
NSLog(@"realContactList = %@",realContactList);
#pragma mark - 拉群具体实现
-(void)pullToGroup{
idcontactMgr = [[%c(MMServiceCenter) defaultCenter] getService:[%c(CContactMgr)class]];
//NSMutableArray *contactList = [contactMgr getContactList:0 contactType:0];
NSMutableArray *contactList = [contactMgr getContactList:1contactType:0];
//NSMutableArray *contactListFour = [contactMgr getContactList:2 contactType:0];
//NSMutableArray *contactListFif = [contactMgr getContactList:3 contactType:0];
idobj = contactList[0];
//NSLog(@"obj class = %@",[obj class]);//CContact
idDC = [%c(MMServiceCenter) defaultCenter];
CContactMgr *contactManager = [DC getService:[%c(CContactMgr)class]];
idselfContact = [contactManager getSelfContact];//CContact类继承于CBaseContact
NSMutableArray *realContactList = [NSMutableArraynew];
//便利联系人 获取剔除自己后的数组
for(CContact *contactincontactList) {
if([contact isNormalFriendContact] && ![[contact getContactDisplayUsrName] isEqualToString:[selfContact getContactDisplayUsrName]]){
FriendEntity *entity = [FriendEntitynew];
//username nickname
entity.wxid = contact.m_nsUsrName;
entity.username = [contact getContactDisplayUsrName];
entity.nickname = [contact getContactDisplayName];
[realContactList addObject:entity];
NSLog(@"该好友符合 getContactDisplayName = %@",[contact getContactDisplayName]);
NSLog(@"m_nsUsrName = %@",contact.m_nsUsrName);
}else{
//NSLog(@"该好友不符合 getContactDisplayName = %@",[contact getContactDisplayName]);
}
}
//NSLog(@"realContactList = %@",realContactList);
NSMutableArray *pullContactList = [NSMutableArraynew];
for(FriendEntity *entityinrealContactList){
//[pullContactList addObject:@{@"m_nsMemberName":entity.username,@"m_uiMemberStatus":@"0",@"m_nsNickName":@"null"}];
GroupMember *member = [[%c(GroupMember) alloc] init];
member.m_nsMemberName = entity.wxid;
member.m_nsNickName = entity.nickname;
member.m_uiMemberStatus =0;
[pullContactList addObject:member];
}
NSLog(@"pullContactList = %@",pullContactList);
if(currentChatRoomName.length >0){
NSLog(@"currentChatRoomName = %@",currentChatRoomName);
idobjc = pullContactList[0];
NSLog(@"objc = %@",objc);
[[DC getService:[%c(CGroupMgr)class]] AddGroupMember:currentChatRoomName withMemberList:pullContactList withDesp:@"hello"];
}
}
网友评论