This API deletes data from the unified storage.
Using the removeAPDataStorage API
AlipayJSBridge.call('removeAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey",
}, function(result) {
alert(JSON.stringify(result));
});Code example
<button id="J_saveDataBtn" class="btn">Save data</button>
<button id="J_getDataBtn" class="btn">View data</button>
<button id="J_removeDataBtn" class="btn">Delete data</button>
<script>
function ready(callback) {
// If jsbridge is already injected, call it directly.
if (window.AlipayJSBridge) {
callback && callback();
} else {
// If not, listen for the injection event.
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
document.querySelector('#J_saveDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('setAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey",
value: "customValue"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
document.querySelector('#J_getDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('getAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
document.querySelector('#J_removeDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('removeAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
}, false);
</script>API reference
AlipayJSBridge.call('removeAPDataStorage', {
type, business, key
});Input parameters
Property | Type | Description | Required | Default value |
type | string | The storage dimension. Valid values: | N | "common" |
business | string | A custom business identifier. You can define this identifier by convention with the corresponding client access code. The default value is On Android, this business identifier corresponds to the | No | "" |
key | string | The key of the custom data. | Yes. | "" |
Output parameters
The parameter passed to the callback function is result: {success}.
Property | Type | Description |
success | bool | Indicates whether the data is deleted successfully. |