Inviting Members
Product deprecation notice
Effective April 30th, 2026, Vonage In-App Messaging will no longer be available. Access for new users will be closed, and the service will be discontinued for all existing users.
If you have any questions regarding this product’s discontinuation, please contact your account manager or our support team.
Overview
This guide covers inviting users to a conversation (members), listening for invites to join a conversation as well as new members joining.
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.
This guide will introduce you to the following concepts.
- Invites - you can invite users to a conversation
- Application Events -
member:invitedevents that fire on an Application, before you are a Member of a Conversation - Conversation Events -
member:joinedandtextevents that fire on a Conversation, after you are a Member
Listening for Conversation invites and accepting them
Achieved by adding a listener on the application object for the member:invited event:
app.on("member:invited", (member, event) => {
//identify the sender and type of conversation.
if (event.body.cname.indexOf("CALL") != 0 && member.invited_by) {
console.log("*** Invitation received:", event);
//accept an invitation.
app.getConversation(event.cid || event.body.cname)
.then((conversation) => {
conversation
.join()
.then(() => {
...
})
.catch(this.errorLogger)
})
.catch(this.errorLogger)
}
})
Add NXMClientDelegate as an extension to a ViewController or similar, and implement client(_ client: NXMClient, didReceive conversation: NXMConversation):
Note: The first 2 methods below are required when implementing NXMClientDelegate:
Have a ViewController, or similar, conform to NXMClientDelegate and implement client:didReceiveConversation::
Note: The first 2 methods below are required when implementing NXMClientDelegate:
Listening for members who joined a conversation
Listen for the member:joined event on the conversation:
conversation.on("member:joined", (member, event) => {
const date = new Date(Date.parse(event.timestamp))
console.log(`*** ${member.user.name} joined the conversation`)
...
})
Add NXMConversationDelegate as an extension to a ViewController or similar, and implement conversation(_ conversation: NXMConversation, didReceive event: NXMMemberEvent):
Note: The first method below is required when implementing NXMConversationDelegate:
Have a ViewController, or similar, conform to NXMConversationDelegate and implement conversation:didReceiveImageEvent::
Note: The first method below is required when implementing NXMConversationDelegate:
Inviting users to a conversation
Users can be invited to join conversation - their username will be used:
conversation.invite({ user_name: "Jane" }).then((member) => {
console.log(member.state + " user: " + member.user.id + " " + member.user.name);
}).catch((error) => {
console.log(error);
});