更新:查看版本資訊瞭解新功能和產品更新。

撤銷訊息

您的代理程式可以撤銷已傳送的訊息,但 RBM 平台尚未傳送給使用者。如果 RBM 平台成功撤銷訊息,平台會將訊息從使用者的訊息佇列中刪除,而不會傳送該訊息。

當 RBM 平台收到撤銷要求時,平台會傳回 200 OK200 OK 回應無法確認 RBM 平台是否已成功撤銷訊息。

在 RBM 平台處理訊息的過程中,您的代理程式可能偶爾會撤銷撤銷作業。在極少數情況下,代理程式會在啟動撤銷要求後不久,收到該訊息的 DELIVERED 事件

根據「最佳做法」訊息,為避免在一段合理時間後未傳送的訊息,「最佳做法」是撤銷該訊息。合理的時間取決於您的代理程式用途,而且應該夠簡短,方便您透過封鎖簡訊等其他訊息策略來復原訊息,而不會封鎖您的使用者。

範例

下列程式碼會傳送撤銷要求。如需格式設定和值資訊,請參閱 phones.agentMessages.delete

cURL

curl -X DELETE "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages/MESSAGE_ID" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`"

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('../libs/rbm_api_helper');

// 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.samples.lib.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 範例代理程式的摘錄。