For the complete documentation index, see llms.txt. This page is also available as Markdown.

User.getAnonymousKey

函数式 API getAnonymousKey也可以这样使用同样的功能。

功能说明

从迷你应用中获取用户的唯一密钥。可用此密钥识别用户并管理数据。成功时 { type: 'HASH', hash } 形式的值。

Toss App 5.232.0 可在以上使用。

类型

User.getAnonymousKey(): Promise<GetAnonymousKeyResponse>;

Params

Response

type GetAnonymousKeyResponse = {
  hash: string;
  type: "HASH";
};

示例代码

import { User } from "@apps-in-toss/web-framework";

async function handleGetAnonymousKey() {
  try {
    const result = await User.getAnonymousKey();
    console.log("用户密钥:", result.hash);
  } catch (error) {
    console.error(error);
  }
}

这有帮助吗?