撤銷訊息

在以下範例中,rbm_api_helper.js (不供 Python 使用) 會假設您正在使用的檔案位於主應用程式資料夾下方一個目錄。視專案設定而定,您可能需要調整位置。

以下程式碼會使用用戶端程式庫撤銷現有的未送達訊息。

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
   console.log(response);
});
以下程式碼節錄自 RBM 範例服務專員

Java

import com.google.rbm.RbmApiHelper;


try {
   // Create an instance of the RBM API helper
   RbmApiHelper rbmApiHelper = new RbmApiHelper();

   // Stop the message associated with messageId from being delivered
   rbmApiHelper.revokeMessage(messageId, "+12223334444");
} catch(Exception e) {
   e.printStackTrace();
}
這段程式碼是 RBM 範例服務專員的摘錄。

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service

# Stop the message associated with message_id from being delivered
rbm_service.revoke('+12223334444', message_id)
以下程式碼節錄自 RBM 範例服務專員

C#

using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Stop the message associated with messageId from being delivered
rbmApiHelper.RevokeMessage(messageId, "+12223334444");
以下程式碼節錄自 RBM 範例服務專員