文档

移除 AP 数据

更新时间:

此接口用于从统一存储中删除数据。

removeAPDataStorage 接口的使用方法

AlipayJSBridge.call('removeAPDataStorage', {
  type: "common",
  business: "customBusinessKey",
  key: "customKey",
}, function(result) {
  alert(JSON.stringify(result));
});

代码示例

<button id="J_saveDataBtn" class="btn">保存数据</button>
<button id="J_getDataBtn" class="btn">查看数据</button>
<button id="J_removeDataBtn" class="btn">删除数据</button>

<script>
function ready(callback) {
  // 如果 jsbridge 已经注入则直接调用
  if (window.AlipayJSBridge) {
    callback && callback();
  } else {
    // 如果没有注入则监听注入的事件
    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 说明

AlipayJSBridge.call('removeAPDataStorage', {
  type, business, key
});

入参

属性

类型

描述

必填

默认值

type

string

(user、common) 用户维度存储还是公共存储,默认值为 common

N

“common”

business

string

自定义的业务标识,可与相应的客户端存取代码约定,默认值为 NebulaBiz

在 Android 中,该业务标识与创建 APSharedPreferences 时所传入的 GROUD_ID 对应。

N

“”

key

string

自定义数据的 key。

Y

“”

出参

回调函数带入的参数 result: {success}

属性

类型

描述

success

bool

删除是否成功。

  • 本页导读 (0)
文档反馈