注册

iOS 进入程序获取群组id

怎么才能进入程序的时候获取群组id啊?
EMError *error=nil;

    NSArray *myGroups=[[EMClient sharedClient].groupManager getMyGroupsFromServerWithError:&error];

    if (!error)

    {

        NSLog(@"获取成功-----%@",myGroups);

    }
使用这个方法获取到了群组名称,但是进入聊天界面并不能聊天。
已邀请:

lizilong - 80后程序猿

EMTextMessageBody *body = [[EMTextMessageBody alloc] initWithText:@"要发送的消息"];
NSString *from = [[EMClient sharedClient] currentUsername];

//生成Message
EMMessage *message = [[EMMessage alloc] initWithConversationID:@"groupID" from:from to:@"
groupID" body:body ext:nil];
message.chatType = EMChatTypeGroupChat;//设置为群聊消息
消息构造正确吗?
有一个更简单的方法获取群id。
EMError *error=nil;

    NSArray *myGroups=[[EMClient sharedClient].groupManager getMyGroupsFromServerWithError:&error];

    _idArray=[NSMutableArray array];

    for (EMGroup *group in myGroups)

    {

        [_idArray addObject:group.groupId];

    }

要回复问题请先登录注册