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

User.getConsentedData

Functional API getConsentedUserDataYou can use the same feature with it as well.

Feature description

Requests user-consent-based data. If consent is required, it opens the terms webview, and once consent is complete, it returns the data retrieved from the server.

Toss app 5.264.0 You can use it on version and above. Before calling, User.getConsentedData.isSupported()You can check whether it is supported with . Functional API getConsentedUserDatain unsupported versions, undefinedreturns it, and User.getConsentedDatais UNSUPPORTED_APP_VERSION throws an error.

Type

User.getConsentedData(options: GetConsentedUserDataOptions): Promise<ConsentedUserData>;

Params

interface GetConsentedUserDataOptions {
  /** This is the key the server uses to find the user data provision consent text and data bundle. Example: `cud_delivery` */
  consentedUserDataKey: string;
  /** Whether to open the terms webview again even in the `USER_DECLINED` state. The default value is `false`. */
  shouldRequestAgreementWhenUserDeclined?: boolean;
}

Response

type ConsentedUserDataKey =
  | "USER_NAME"
  | "USER_GENDER"
  | "USER_NATIONALITY"
  | "USER_BIRTHDAY"
  | "USER_PHONE"
  | "USER_ADDRESS"
  | "USER_EMAIL"
  | "USER_CONSUMPTION_HISTORY";

type ConsentedUserData = Partial<Record<ConsentedUserDataKey, string>>;

Only the keys corresponding to the requested items can be included.

Error

The error code is the error.code value.

Code
Description

UNSUPPORTED_APP_VERSION

If the running version of the Toss app doesn't support this feature, it occurs immediately upon call. User.getConsentedData.isSupported()Check in advance with error.messageand, if it occurs, show the user the (update guidance message).

USER_DECLINED

This is the case when the user explicitly declined and there is no retry request option, or when they declined in the terms webview.

UNAVAILABLE

This is the case when the server cannot determine whether the user has consented.

TERMS_NOT_SET

This is the case when the mini app does not have the user data provision consent text set.

INVALID_REQUEST

consentedUserDataKeyis empty, or termsUrlis missing, or it is not an HTTPS company domain.

CANCELED

This is the case when the terms webview is closed before sending the result.

CONSENTED_USER_DATA_AGREEMENT_FAILED

An error occurred while processing the terms webview.

CONSENTED_USER_DATA_INVALID_DATA

PROVIDEDbut datais missing, or after successful consent the re-query result is PROVIDEDnot

Example code

Was this helpful?