new_releases 更新:查看
版本資訊瞭解新功能和產品更新。
撤銷訊息
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在以下範例中,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 範例服務專員。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-04-10 (世界標準時間)。
[null,null,["上次更新時間:2025-04-10 (世界標準時間)。"],[[["\u003cp\u003eThis page demonstrates how to revoke an undelivered message using the RBM API with code examples in Node.js, Java, Python, and C#.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code snippets show how to utilize the respective language's RBM API helper or client library to stop a message from being delivered, referencing a specific \u003ccode\u003emessageId\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach language example requires referencing a helper library, such as \u003ccode\u003erbmApiHelper\u003c/code\u003e for Node.js, Java and C#, and \u003ccode\u003erbm_service\u003c/code\u003e for Python.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003erevokeMessage\u003c/code\u003e or \u003ccode\u003erevoke\u003c/code\u003e function is used in all examples to revoke a message associated with a provided \u003ccode\u003emessageId\u003c/code\u003e, and each language shows the necessary parameters.\u003c/p\u003e\n"]]],[],null,["# Revoke messages\n\nIn the following example, `rbm_api_helper.js` (not used for Python) assumes the\nfile you are working in is one directory below the main app folder. You may\nneed to adjust the location depending on your project's configuration.\n\nThe following code [revokes](/business-communications/rcs-business-messaging/guides/build/messages/revoke) an existing, undelivered message with a\nclient library. \n\n### Node.js\n\n```javascript\n// Reference to RBM API helper\nconst rbmApiHelper = require('@google/rcsbusinessmessaging');\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.revokeMessage('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', messageId, function(err, response) {\n console.log(response);\n});\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Java\n\n```java\nimport com.google.rbm.RbmApiHelper;\n...\n\ntry {\n // Create an instance of the RBM API helper\n RbmApiHelper rbmApiHelper = new RbmApiHelper();\n\n // Stop the message associated with messageId from being delivered\n rbmApiHelper.revokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n} catch(Exception e) {\n e.printStackTrace();\n}\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### Python\n\n```python\n# Reference to RBM Python client helper and messaging object structure\nfrom rcs_business_messaging import rbm_service\n\n# Stop the message associated with message_id from being delivered\nrbm_service.revoke('\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e', message_id)\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples).\n\n### C#\n\n```c#\nusing RCSBusinessMessaging;\n...\n\n// Create an instance of the RBM API helper\nRbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,\n projectId);\n\n// Stop the message associated with messageId from being delivered\nrbmApiHelper.RevokeMessage(messageId, \"\u003cvar fieldlabel=\"Phone number\" translate=\"no\"\u003e+12223334444\u003c/var\u003e\");\n```\nThis code is an excerpt from an [RBM sample agent](/business-communications/rcs-business-messaging/samples)."]]