onRecvMessageRevoked
notification which contains the msgID
of the recalled message. You can identify the recalled message at the UI layer based on the msgID
and change the bubble for the message to the "Message recalled" status.V2TIMManager.getMessageManager().revokeMessage(v2TIMMessage, new V2TIMCallback() {@Overridepublic void onError(int code, String desc) {// The message failed to be recalled}@Overridepublic void onSuccess() {// Message recalled successfully}});
// `selectedMessage` is the message to be recalled.[[V2TIMManager sharedInstance] revokeMessage:selectedMessagesucc:^{// Message recalled successfully} fail:^(int code, NSString *msg) {// The message failed to be recalled}];
class Callback final : public V2TIMCallback {public:using SuccessCallback = std::function<void()>;using ErrorCallback = std::function<void(int, const V2TIMString&)>;Callback() = default;~Callback() override = default;void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {success_callback_ = std::move(success_callback);error_callback_ = std::move(error_callback);}void OnSuccess() override {if (success_callback_) {success_callback_();}}void OnError(int error_code, const V2TIMString& error_message) override {if (error_callback_) {error_callback_(error_code, error_message);}}private:SuccessCallback success_callback_;ErrorCallback error_callback_;};auto callback = new Callback;callback->SetCallback([=]() {// Message recalled successfullydelete callback;},[=](int error_code, const V2TIMString& error_message) {// The message failed to be recalleddelete callback;});V2TIMManager::GetInstance()->GetMessageManager()->RevokeMessage(message, callback);
addAdvancedMsgListener
(Android / iOS and macOS / Windows) to set the advanced message listener.onRecvMessageRevoked
(Android / iOS & Mac / Windows) .V2TIMManager.getMessageManager().addAdvancedMsgListener(new V2TIMAdvancedMsgListener() {@Overridefor (V2TIMMessage msg : msgList) {if (msg.getMsgID().equals(msgID)) {// You need to change the bubble status for the message on the UI after receiving the message recall notification.}}}}
// V2TIMAdvancedMsgListener- (void)onRecvMessageRevoked:(NSString *)msgID operateUser:(V2TIMUserFullInfo *)operateUser reason:(NSString *)reason {// You need to change the bubble status for the message on the UI after receiving the message recall notification.}
class AdvancedMsgListener final : public V2TIMAdvancedMsgListener {public:/*** Received a new message** @param message Message*//*** Received a message recall notification** @param messageID Unique message ID*/void OnRecvMessageRevoked(const V2TIMString& messageID,// `msgList` is the message list on the current chat interface}// Other members …};// Add an event listener for advanced messages. Keep `advancedMsgListener` valid before it is removed to ensure event callbacks are received.AdvancedMsgListener advancedMsgListener;V2TIMManager::GetInstance()->GetMessageManager()->AddAdvancedMsgListener(&advancedMsgListener);
Was this page helpful?