Get Member(s) Information

Overview

This guide covers getting the Members of a Conversation, your Member information and another Member's Information.

Before you begin, make sure you added the SDK to your app and you are able to create a conversation.

NOTE: A step-by-step tutorial to build a chat application is available here.

Get the Members

To get a list of Members of a Conversation that you are also currently a Member:

const params = {
    order: "desc", // default "asc"
    page_size: 100 // default 10
}
conversation.getMembers(params).then((members_page) => {
    members_page.items.forEach(member => {
        console.log("Member: ", member);
    })
}).catch((error) => {
    console.error("error getting the members ", error);
});
conversation.getMembers(100, NexmoPageOrder.NexmoMPageOrderAsc, object : NexmoRequestListener<NexmoMembersSummaryPage> {
    override fun onError(error: NexmoApiError) {}

    override fun onSuccess(membersSummaryPage: NexmoMembersSummaryPage?) {
        val members = membersSummaryPage?.pageResponse?.data?.joinToString(separator = " ")
        Log.d("Members", members)
    }
})
conversation.getMembers(100, NexmoPageOrder.NexmoMPageOrderAsc, new NexmoRequestListener<NexmoMembersSummaryPage>() {
    @Override
    public void onError(@NonNull @NotNull NexmoApiError error) {}

    @Override
    public void onSuccess(@Nullable @org.jetbrains.annotations.Nullable NexmoMembersSummaryPage membersSummaryPage) {
        Collection<NexmoMemberSummary> members = membersSummaryPage.getPageResponse().getData();
    }
});
conversation.getMembersPage(withPageSize: 100, order: .asc) { error, membersPage in
    guard let membersPage = membersPage, error == nil else { return }
    print(membersPage.memberSummaries)
}
[conversation getMembersPageWithPageSize:100 order:NXMPageOrderAsc completion:^(NSError * _Nullable error, NXMMembersSummaryPage * _Nullable page) {
    if (!error && page) {
        NSLog(@"%@", page.memberSummaries);
    }
}];

Get your Member

To get your Member's information:

conversation.getMyMember().then((member) => {
    console.log("Member: ", member);
}).catch((error) => {
    console.error("error getting my member", error);
});
val member = conversation.myMember
val member = conversation.getMyMember();
let myMember = conversation?.myMember
NXMMember *myMember = conversation.myMember;

Get another Member

To get another Member's information (Note: You will need their Member ID):

conversation.getMember("MEM-id").then((member) => {
    console.log("Member: ", member);
}).catch((error) => {
    console.error("error getting member", error);
});
conversation.getMember("MEMBER_ID", object : NexmoRequestListener<NexmoMember?> {
    override fun onError(error: NexmoApiError) {}

    override fun onSuccess(member: NexmoMember?) {
        Log.d("Member", member?.user?.displayName)
    }
})
conversation.getMember("MEMBER_ID", new NexmoRequestListener<NexmoMember>() {
    @Override
    public void onError(@NonNull @NotNull NexmoApiError error) {}

    @Override
    public void onSuccess(@Nullable @org.jetbrains.annotations.Nullable NexmoMember member) {
        Log.d("Member", member.getUser().getDisplayName());
    }
});
conversation.getMemberWithMemberUuid("MEM_ID") { error, member in
    guard let member = member, error == nil else { return }
    print(member)
}
[conversation getMemberWithMemberUuid:@"MEM_ID" completion:^(NSError * _Nullable error, NXMMember * _Nullable member) {
    if (!error && member) {
        NSLog(@"%@", member);
    }
}];

Reference