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

Notification.requestAgreement

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

Feature description

Request the notification consent screen, and pass the consent result onEvent as a callback. Toss app Android/iOS 5.255.0 It can be used on the above.

options.templateCodeIn options.templateCode, please enter the template code created in Apps in Toss Console > Mini App > Smart Sending.

It works in an event-driven style, and as a return value, it gives you a function that releases the App Bridge callback. When the result comes in, be sure to release it.

Before calling Notification.requestAgreement.isSupported()you can check whether it is supported. If you call it on an unsupported version, UNSUPPORTED_APP_VERSION An error occurs. The functional API requestNotificationAgreementattempts to subscribe regardless of version.

Type

Notification.requestAgreement(params: RequestNotificationAgreementOptions): () => void;

Params

interface RequestNotificationAgreementOptions {
  options: { templateCode: string };
  onEvent: (result: { type: NotificationAgreementResult }) => void;
  onError: (error: unknown) => void | Promise<void>;
}

type NotificationAgreementResult =
  "newAgreement" | "alreadyAgreed" | "agreementRejected";

Response

Returns a cleanup function that releases the App Bridge callback.

Error

Error codes are onErrorcan be received as, or wrapped around the try/catcherrors caught in 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. Notification.requestAgreement.isSupported()Check in advance with error.messageand, if it occurs, show the user the (update guidance message).

Example code

Was this helpful?