这份文档还在翻译中,预期年底前完成。欢迎您提供宝贵的意见及建议。

Leave Conversation

This guide covers the process of leaving a conversation.

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

Given a conversation you are already a member of, you can stop being an active member of it by leaving the conversation:

conversation.leave()
conversation?.allMembers?.firstOrNull()?.let {
    conversation.kick(it, object : NexmoRequestListener<Any> {
        override fun onSuccess(p0: Any?) {
            Log.d("TAG", "User kick success")
        }

        override fun onError(apiError: NexmoApiError) {
            Log.d("TAG", "Error: Unable to kick user ${apiError.message}")
        }
    })
}
if (conversation.getAllMembers().size() > 0) {
    NexmoMember member = conversation.getAllMembers().iterator().next();

    conversation.kick(member, new NexmoRequestListener<Void>() {
        @Override
        public void onSuccess(@Nullable Void aVoid) {
            Log.d("TTAG", "User kick success");
        }

        @Override
        public void onError(@NonNull NexmoApiError apiError) {
            Log.d("TTAG", "Error: Unable to kick user " + apiError.getMessage());
        }
    });
}
conversation.leave({ (error) in
    if let error = error {
        NSLog("Error leaving conversation: \(error.localizedDescription)")
        return
    }
    NSLog("Conversation left.")
})
[self.conversation leave:^(NSError * _Nullable error) {
    if (error) {
        NSLog(@"Error leaving conversation: %@", error);
        return;
    }
    NSLog(@"Conversation left.");
}];