import * as _apps_in_toss_types from '@apps-in-toss/types'; import { CompatiblePlaceholderArgument, PermissionName, PermissionAccess, PermissionStatus, ContactResult, ImageResponse, Location, StartUpdateLocationEventParams, Accuracy, LoadAdMobParams, ShowAdMobParams, IsAdMobLoadedOptions, FetchAlbumPhotos, FetchContacts, GetClipboardText, GetCurrentLocation, SetClipboardText, OpenCamera } from '@apps-in-toss/types'; export { IsAdMobLoadedOptions, LoadAdMobEvent, LoadAdMobOptions, LoadAdMobParams, ShowAdMobEvent, ShowAdMobOptions, ShowAdMobParams, StartUpdateLocationPermissionError } from '@apps-in-toss/types'; import { GraniteEventDefinition, GraniteEvent } from '@granite-js/react-native'; import { AnyObject } from 'brick-module'; interface AppsInTossSignTossCertParams { txId: string; } /** * @public * @category 토스인증 * @name appsInTossSignTossCert * @description 토스 인증서를 사용해 서명하는 기능을 제공해요. 이 함수를 사용하면 앱인토스에서 제공하는 인증서를 활용해 서명을 할 수 있어요. * * @param {AppsInTossSignTossCertParams} params - 서명에 필요한 파라미터를 포함하는 객체예요. * @param {string} params.txId - 토스인증서를 사용한 본인확인이나 간편인증, 전자서명에서 사용하는 Transaction Id예요. * * @example * ```tsx * import { appsInTossSignTossCert } from '@apps-in-toss/framework'; * * // 서명에 필요한 파라미터를 정의해요. * const params = { * txId: "f2e1a6df..." * }; * * appsInTossSignTossCert(params) * .then(() => { * console.log('서명 작업이 성공적으로 완료되었어요.'); * }) * .catch((error) => { * console.error('서명 작업 중 에러가 발생했어요:', error); * }); * ``` */ declare function appsInTossSignTossCert(params: AppsInTossSignTossCertParams): Promise; /** * @public * @category 토스페이 * @name CheckoutPaymentOptions * @description 토스페이 결제창을 띄울 때 필요한 옵션이에요. * @property {string} payToken 결제 토큰이에요. */ interface CheckoutPaymentOptions { /** * 결제 토큰이에요. */ payToken: string; } /** * @public * @category 토스페이 * @name CheckoutPaymentResult * @description 토스페이 결제창에서 사용자가 인증에 성공했는지 여부예요. * @property {boolean} success 인증이 성공했는지 여부예요. * @property {string} [reason] 인증이 실패했을 경우의 이유예요. */ interface CheckoutPaymentResult { /** * 인증이 성공했는지 여부예요. */ success: boolean; /** * 인증이 실패했을 경우의 이유예요. */ reason?: string; } /** * @public * @category 토스페이 * @name checkoutPayment * @description 토스페이 결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요. * * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요. * * @param {CheckoutPaymentOptions} options 결제창을 띄울 때 필요한 옵션이에요. * @returns {Promise} 인증 성공 여부를 포함한 결과를 반환해요. * * @example * * ### 토스페이 결제창 띄우고 인증 처리하기 * * ```tsx * import { TossPay } from '@apps-in-toss/framework'; * * async function handlePayment() { * try { * // 실제 구현 시 결제 생성 역할을 하는 API 엔드포인트로 대체해주세요. * const { payToken } = await fetch('/my-api/payment/create').then(res => res.json()); * * const { success, reason } = await TossPay.checkoutPayment({ payToken }); * * if (success) { * // 실제 구현 시 결제를 실행하는 API 엔드포인트로 대체해주세요. * await fetch('/my-api/payment/execute', { * method: 'POST', * body: JSON.stringify({ payToken }), * headers: { 'Content-Type': 'application/json' }, * }); * } else { * console.log('인증 실패:', reason); * } * } catch (error) { * console.error('결제 인증 중 오류가 발생했어요:', error); * } * } * ``` */ declare function checkoutPayment(options: { params: CheckoutPaymentOptions; }): Promise; interface GetAnonymousKeySuccessResponse { hash: string; type: 'HASH'; } type GetAnonymousKeyResponse = GetAnonymousKeySuccessResponse; /** * @public * @name getAnonymousKey * @description * 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 데이터를 관리할 수 있어요. * @returns {Promise} * 사용자 키 조회 결과를 반환해요. * - `GetAnonymousKeyResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요. * - `'ERROR'`: 알 수 없는 오류가 발생했어요. * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요. * * @example * ```tsx * // react-native * import { Button } from 'react-native'; * import { getAnonymousKey } from '@apps-in-toss/framework'; * * function UserKeyButton() { * async function handlePress() { * const result = await getAnonymousKey(); * * if (!result) { * console.warn('지원하지 않는 앱 버전이에요.'); * return; * } * * if (result === 'ERROR') { * console.error('사용자 키 조회 중 오류가 발생했어요.'); * return; * } * * if (result.type === 'HASH') { * console.log('사용자 키:', result.hash); * // 여기에서 사용자 키를 사용해 데이터를 관리할 수 있어요. * } * } * * return ( * * ); * } * ``` */ declare function getAnonymousKey(): Promise; /** * @category 게임센터 * @name GameCenterGameProfileResponse * @description 토스게임센터 프로필을 가져온 결과 타입이에요. * 앱에 프로필이 없는 경우, `statusCode`가 `'PROFILE_NOT_FOUND'`이고 다른 정보는 없어요. * 프로필이 있는 경우 `statusCode`가 `'SUCCESS'`이고, 닉네임과 프로필 이미지 주소가 함께 제공돼요. * @property {string} statusCode 프로필 조회 결과 상태예요. `'SUCCESS'` 또는 `'PROFILE_NOT_FOUND'` 중 하나예요. * @property {string} [nickname] 프로필 닉네임이에요. `statusCode`가 `'SUCCESS'`일 때만 있어요. * @property {string} [profileImageUri] 프로필 이미지 URL이에요. `statusCode`가 `'SUCCESS'`일 때만 있어요. */ type GameCenterGameProfileResponse = { statusCode: 'PROFILE_NOT_FOUND'; } | { statusCode: 'SUCCESS'; nickname: string; profileImageUri: string; }; /** * @category 게임센터 * @name getGameCenterGameProfile * @description 토스게임센터 프로필 정보를 가져와요. * 사용자가 프로필을 만들지 않았다면 `statusCode`가 `'PROFILE_NOT_FOUND'`인 응답이 반환돼요. * 앱 버전이 최소 지원 버전(안드로이드 5.221.0, iOS 5.221.0)보다 낮으면 `undefined`를 반환해요. * @returns {Promise} 프로필 정보 또는 `undefined`를 반환해요. * * @example * ### 게임센터 프로필 가져오기 * ```tsx * import { getGameCenterGameProfile } from './getGameCenterGameProfile'; * import { useState } from 'react'; * import { View, Button } from 'react-native'; * * function GameProfile() { * const [profile, setProfile] = useState(null); * * const handlePress = async () => { * try { * const result = await getGameCenterGameProfile(); * if (result) { * setProfile(result); * } * } catch (error) { * console.error('게임센터 프로필 가져오기에 실패했어요.', error); * } * }; * * return ( * * * ); * } * ``` */ declare function grantPromotionRewardForGame(params: { params: { promotionCode: string; amount: number; }; }): Promise; type Sku = { /** * @deprecated `productId`는 더 이상 사용하지 않아요. 대신 `sku`를 사용해요. */ productId: string; sku?: string; } | { productId?: never; sku: string; }; /** * @public * @category 인앱결제 * @name IapCreateOneTimePurchaseOrderResult * @description 인앱결제 1건이 완료되면 결제 세부 정보와 상품 정보를 담아 반환해요. 반환된 정보로 결제한 상품의 정보를 화면에 표시할 수 있어요. * @property {string} orderId - 결제 주문 ID이에요. 결제 완료 후 [결제 상태를 조회](https://developers-apps-in-toss.toss.im/api/getIapOrderStatus.html)할 때 사용해요. * @property {string} displayName - 화면에 표시할 상품 이름이에요. * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요. * @property {number} amount - 상품 가격 숫자 값이에요. 화폐 단위와 쉼표를 제외한 순수 숫자예요. 예를 들어 `1000`으로 표시돼요. * @property {string} currency - [ISO 4217 표준](https://ko.wikipedia.org/wiki/ISO_4217)에 따른 상품 가격 통화 단위예요. 예를 들어 원화는 `KRW`, 달러는 `USD`로 표시돼요. * @property {number} fraction - 가격을 표시할 때 소수점 아래 몇 자리까지 보여줄지 정하는 값이에요. 예를 들어 달러는 소수점 둘째 자리까지 보여줘서 `2`, 원화는 소수점이 필요 없어서 `0`이에요 * @property {string | null} miniAppIconUrl - 미니앱 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. 콘솔에서 아이콘을 등록하지 않았다면 `null`로 반환돼요. */ interface IapCreateOneTimePurchaseOrderResult { orderId: string; displayName: string; displayAmount: string; amount: number; currency: string; fraction: number; miniAppIconUrl: string | null; } interface OneTimePurchaseSuccessEvent { type: 'success'; data: IapCreateOneTimePurchaseOrderResult; } interface PurchasedEvent { type: 'purchased'; data: { orderId: string; }; } /** * @public * @category 인앱결제 * @name IapCreateOneTimePurchaseOrderOptions * @property {Sku} options - 결제할 상품의 정보예요. * @property {string} options.sku - 주문할 상품의 고유 ID예요. * @property {(params: { orderId: string }) => boolean | Promise} processProductGrant - 주문이 만들어진 뒤 실제로 상품을 지급할 때 호출해요. `orderId`를 받아서 지급 성공 여부를 `true` 또는 `Promise`로 반환해요. 지급에 실패하면 `false`를 반환해요. * @property {(event: SuccessEvent) => void | Promise} onEvent - 결제가 성공했을 때 호출해요. `event.type`이 `'success'`이고, `event.data`에 `IapCreateOneTimePurchaseOrderResult`가 들어 있어요. * @property {(error: unknown) => void | Promise} onError - 결제 과정에서 에러가 발생했을 때 호출해요. 에러 객체를 받아서 로깅하거나 복구 절차를 실행할 수 있어요. */ interface IapCreateOneTimePurchaseOrderOptions { options: Sku & { processProductGrant: (params: { orderId: string; }) => boolean | Promise; }; onEvent: (event: OneTimePurchaseSuccessEvent) => void | Promise; onError: (error: unknown) => void | Promise; } interface IapRequestOneTimePurchaseOptions { options: Sku; onEvent: (event: PurchasedEvent | OneTimePurchaseSuccessEvent) => void | Promise; onError: (error: unknown) => void | Promise; } declare function iapCreateOneTimePurchaseOrder(params: Sku): Promise; declare function processProductGrant(params: { orderId: string; isProductGranted: boolean; }): Promise; declare function requestOneTimePurchase(params: IapRequestOneTimePurchaseOptions): () => void; /** * @public * @category 인앱결제 * @name createOneTimePurchaseOrder * @description * 특정 인앱결제 주문서 페이지로 이동해요. 사용자가 상품 구매 버튼을 누르는 상황 등에 사용할 수 있어요. 사용자의 결제는 이동한 페이지에서 진행돼요. 만약 결제 중에 에러가 발생하면 에러 유형에 따라 에러 페이지로 이동해요. * @param {IapCreateOneTimePurchaseOrderOptions} params - 인앱결제를 생성할 때 필요한 정보예요. * @returns {() => void} 앱브릿지 cleanup 함수를 반환해요. 인앱결제 기능이 끝나면 반드시 이 함수를 호출해서 리소스를 해제해야 해요. * * @throw {code: "INVALID_PRODUCT_ID"} - 유효하지 않은 상품 ID이거나, 해당 상품이 존재하지 않을 때 발생해요. * @throw {code: "PAYMENT_PENDING"} - 사용자가 요청한 결제가 아직 승인을 기다리고 있을 때 발생해요. * @throw {code: "NETWORK_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요. * @throw {code: "INVALID_USER_ENVIRONMENT"} - 특정 기기, 계정 또는 설정 환경에서 구매할 수 없는 상품일 때 발생해요. * @throw {code: "ITEM_ALREADY_OWNED"} - 사용자가 이미 구매한 상품을 다시 구매하려고 할 때 발생해요. * @throw {code: "APP_MARKET_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 앱스토어에서 사용자 정보 검증에 실패했을 때 발생해요. 사용자가 앱스토어에 문의해서 환불을 요청해야해요. * @throw {code: "TOSS_SERVER_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 서버 전송에 실패해서 결제 정보를 저장할 수 없을 때 발생해요. * @throw {code: "INTERNAL_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요. * @throw {code: "KOREAN_ACCOUNT_ONLY"} - iOS 환경에서 사용자의 계정이 한국 계정이 아닐 때 발생해요. * @throw {code: "USER_CANCELED"} - 사용자가 결제를 완료하지 않고 주문서 페이지를 이탈했을 때 발생해요. * @throw {code: "PRODUCT_NOT_GRANTED_BY_PARTNER"} - 파트너사의 상품 지급이 실패했을 때 발생해요. * * @example * ### 특정 인앱결제 주문서 페이지로 이동하기 * * ```tsx * import { IAP } from "@apps-in-toss/web-framework"; * import { Button } from "@toss/tds-react-native"; * import { useCallback } from "react"; * * interface Props { * sku: string; * } * * function IapCreateOneTimePurchaseOrderButton({ sku }: Props) { * const handleClick = useCallback(async () => { * * const cleanup = await IAP.createOneTimePurchaseOrder({ * options: { * sku, * processProductGrant: ({ orderId }) => { * // 상품 지급 로직 작성 * return true; // 상품 지급 여부 * } * }, * onEvent: (event) => { * console.log(event); * }, * onError: (error) => { * console.error(error); * }, * }); * * return cleanup; * }, []); * * return ; * } * ``` */ declare function createOneTimePurchaseOrder(params: IapCreateOneTimePurchaseOrderOptions): () => void; interface BasicProductListItem { sku: string; displayAmount: string; displayName: string; iconUrl: string; description: string; } type Offer = { type: 'FREE_TRIAL'; offerId: string; period: string; } | { type: 'NEW_SUBSCRIPTION'; offerId: string; period: string; displayAmount: string; } | { type: 'RETURNING'; offerId: string; period: string; displayAmount: string; }; /** * @public * @category 인앱결제 * @name ConsumableProductListItem * @description 소모품 상품 정보를 담은 객체예요. * @property {string} sku - 상품의 고유 ID예요. * @property {string} type - 상품의 유형이에요. `CONSUMABLE`을 나타내요. * @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요. * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요. * @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. * @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요. */ interface ConsumableProductListItem extends BasicProductListItem { type: 'CONSUMABLE'; } /** * @public * @category 인앱결제 * @name NonConsumableProductListItem * @description 비소모품 상품 정보를 담은 객체예요. * @property {string} sku - 상품의 고유 ID예요. * @property {string} type - 상품의 유형이에요. `NON_CONSUMABLE`을 나타내요. * @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요. * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요. * @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. * @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요. */ interface NonConsumableProductListItem extends BasicProductListItem { type: 'NON_CONSUMABLE'; } /** * @public * @category 인앱결제 * @name SubscriptionProductListItem * @description 자동 갱신 구독 상품 정보를 담은 객체예요. * @property {string} sku - 상품의 고유 ID예요. * @property {string} type - 상품의 유형이에요. `SUBSCRIPTION`을 나타내요. * @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요. * @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요. * @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. * @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요. * @property {string} renewalCycle - 구독 갱신 주기이에요. `WEEKLY`, `MONTHLY`, `YEARLY` 중 하나를 나타내요. * @property {Offer[]} offers - 구독 혜택 옵션 목록이에요. 각 옵션은 하나의 구독 혜택을 나타내요. * @property {string} offers[].type - 구독 혜택 옵션 유형이에요. `FREE_TRIAL`, `NEW_SUBSCRIPTION`, `RETURNING` 중 하나를 나타내요. * @property {string} offers[].offerId - 구독 혜택 옵션의 고유 ID예요. * @property {string} offers[].period - 구독 혜택 옵션의 적용 기간이에요. * @property {string} offers[].displayAmount - 통화 단위가 포함된 구독 혜택 옵션의 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요. */ interface SubscriptionProductListItem extends BasicProductListItem { type: 'SUBSCRIPTION'; renewalCycle: 'WEEKLY' | 'MONTHLY' | 'YEARLY'; offers?: Offer[]; } /** * @public * @category 인앱결제 * @name IapProductListItem * @description 인앱결제로 구매할 수 있는 상품 하나의 정보를 담은 객체예요. 상품 목록을 화면에 표시할 때 사용해요. */ type IapProductListItem = ConsumableProductListItem | NonConsumableProductListItem | SubscriptionProductListItem; /** * @public * @category 인앱결제 * @name getProductItemList * @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요. * @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요. * * @example * ### 구매 가능한 인앱결제 상품목록 가져오기 * * ```tsx * import { IAP, IapProductListItem } from "@apps-in-toss/framework"; * import { Button, List, ListRow } from "@toss/tds-react-native"; * import { useEffect, useState } from "react"; * * function IapProductList() { * const [products, setProducts] = useState([]); * * async function buyIapProduct(productId: string) { * try { * await IAP.createOneTimePurchaseOrder({ * productId, * }); * * console.error("인앱결제에 성공했어요"); * } catch (error) { * console.error("인앱결제에 실패했어요:", error); * } * } * * useEffect(() => { * async function fetchProducts() { * try { * const response = await IAP.getProductItemList(); * setProducts(response?.products ?? []); * } catch (error) { * console.error("상품 목록을 가져오는 데 실패했어요:", error); * } * } * * fetchProducts(); * }, []); * * return ( * * {products.map((product) => ( * * } * right={ * * } * contents={ * * } * /> * ))} * * ); * } * ``` */ declare function getProductItemList(): Promise<{ products: any[]; } | undefined>; /** * @public * @category 인앱결제 * @name getPendingOrders * @description 대기 중인 주문 목록을 가져와요. 이 함수를 사용하면 결제가 아직 완료되지 않은 주문 정보를 확인할 수 있어요. * @returns {Promise<{ orders: { orderId: string; sku: string; paymentCompletedDate: string; }[]}>} 대기 중인 주문의 배열을 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.234.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요. * * @example * ### 대기 중인 주문 목록 가져오기 * ```typescript * import { IAP } from '@apps-in-toss/framework'; * * async function fetchOrders() { * try { * const pendingOrders = await IAP.getPendingOrders(); * return pendingOrders; * } catch (error) { * console.error(error); * } * } * ``` */ declare function getPendingOrders(): Promise<{ orders: Array<{ orderId: string; sku: string; }>; } | undefined>; /** * @public * @category 인앱결제 * @name CompletedOrRefundedOrdersResult * @description 인앱결제로 구매하거나 환불한 주문 목록을 나타내는 객체예요. 페이지네이션 정보를 포함해요. * @property {boolean} hasNext 다음 페이지가 있는지 여부예요. `true`면 더 많은 주문이 남아 있어요. * @property {string | null} [nextKey] 다음 주문 목록을 조회할 때 사용할 키예요. 마지막 페이지라면 `null`이거나 생략될 수 있어요. * @property {Array} orders 주문 정보를 담은 배열이에요. 각 요소는 하나의 주문을 나타내요. * @property {string} orders[].orderId 주문의 고유 ID예요. * @property {string} orders[].sku 주문 상품의 고유 ID예요. * @property {'COMPLETED' | 'REFUNDED'} orders[].status 주문의 상태예요. 'COMPLETED'는 주문이 완료된 상태, 'REFUNDED'는 환불된 상태를 의미해요. * @property {string} orders[].date 주문의 날짜 정보예요. ISO 8601 형식(YYYY-MM-DDTHH:mm:ss)을 사용해요. 예를 들어 "2025-09-22T00:00:00" 형식으로 제공돼요. 주문 상태가 `COMPLETED`라면 주문한 날짜를, `REFUNDED`라면 환불한 날짜를 나타내요. */ interface CompletedOrRefundedOrdersResult { hasNext: boolean; nextKey?: string | null; orders: { orderId: string; sku: string; status: 'COMPLETED' | 'REFUNDED'; date: string; }[]; } /** * @public * @category 인앱결제 * @name getCompletedOrRefundedOrders * @description 인앱결제로 구매하거나 환불한 주문 목록을 가져와요. * @returns {Promise} 페이지네이션을 포함한 주문 목록 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.231.0, iOS 5.231.0)보다 낮으면 `undefined`를 반환해요. * * @example * ```typescript * import { IAP } from "@apps-in-toss/framework"; * * async function fetchOrders() { * try { * const response = await IAP.getCompletedOrRefundedOrders(); * return response; * } catch (error) { * console.error(error); * } * } * ``` */ declare function getCompletedOrRefundedOrders(params?: { key?: string | null; }): Promise; /** * @public * @category 인앱결제 * @name completeProductGrant * @description 상품 지급 처리를 완료했다는 메시지를 앱에 전달해요. 이 함수를 사용하면 결제가 완료된 주문의 상품 지급이 정상적으로 완료되었음을 알릴 수 있어요. * @param {{ params: { orderId: string } }} params 결제가 완료된 주문 정보를 담은 객체예요. * @param {string} params.orderId 주문의 고유 ID예요. 상품 지급을 완료할 주문을 지정할 때 사용해요. * @returns {Promise} 상품 지급이 완료됐는지 여부를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.233.0, iOS 5.233.0)보다 낮으면 `undefined`를 반환해요. * * @example * ### 결제를 성공한 뒤 상품을 지급하는 예시 * ```typescript * import { IAP } from '@apps-in-toss/framework'; * * async function handleGrantProduct(orderId: string) { * try { * await IAP.completeProductGrant({ params: { orderId } }); * } catch (error) { * console.error(error); * } * } * ``` */ declare function completeProductGrant(params: { params: { orderId: string; }; }): Promise; /** * @public * @category 인앱결제 * @name IapSubscriptionInfoResult * @description 구독 주문의 현재 상태 정보를 담은 객체예요. * @property {number} catalogId 구독 상품의 식별자예요. * @property {"ACTIVE" |"EXPIRED"|"IN_GRACE_PERIOD"|"ON_HOLD"|"PAUSED"|"REVOKED"} status 구독 상태를 나타내는 값이에요. * @property {string | null} expiresAt 구독 만료 예정 시각이에요. 만료 정보가 없으면 `null`이에요. * @property {boolean} isAutoRenew 구독 자동 갱신 여부예요. * @property {string | null} gracePeriodExpiresAt 결제 유예 기간 만료 시각이에요. 유예 기간이 없으면 `null`이에요. * @property {boolean} isAccessible 현재 구독 상품을 이용할 수 있는지 여부예요. */ interface IapSubscriptionInfoResult { catalogId: number; status: 'ACTIVE' | 'EXPIRED' | 'IN_GRACE_PERIOD' | 'ON_HOLD' | 'PAUSED' | 'REVOKED'; expiresAt: string | null; isAutoRenew: boolean; gracePeriodExpiresAt: string | null; isAccessible: boolean; } /** * @public * @category 인앱결제 * @name getSubscriptionInfo * @description 구독 주문의 현재 상태 정보를 가져와요. * @param {{ params: { orderId: string } }} params 조회할 구독 주문 정보를 담은 객체예요. * @param {string} params.orderId 주문의 고유 ID예요. * @returns {Promise<{ subscription: IapSubscriptionInfoResult } | undefined>} 구독 상태 정보를 담은 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.253.0, iOS 5.250.0)보다 낮으면 `undefined`를 반환해요. * * @example * ### 주문 ID로 구독 상태 조회하기 * ```typescript * import { IAP } from '@apps-in-toss/framework'; * * async function fetchSubscriptionInfo(orderId: string) { * try { * const response = await IAP.getSubscriptionInfo({ params: { orderId } }); * return response?.subscription; * } catch (error) { * console.error(error); * } * } * ``` */ declare function getSubscriptionInfo(params: { params: { orderId: string; }; }): Promise<{ subscription: IapSubscriptionInfoResult; } | undefined>; /** * @public * @category 인앱결제 * @name CreateSubscriptionPurchaseOrderOptions * @description 구독 인앱결제를 생성할 때 필요한 옵션이에요. * @property {object} options - 결제할 구독 상품의 정보예요. * @property {string} options.sku - 주문할 구독 상품의 고유 ID예요. * @property {string | null} [options.offerId] - 적용할 offer ID예요. 없으면 기본 가격이 적용돼요. * @property {(params: { orderId: string, subscriptionId?: string }) => boolean | Promise} options.processProductGrant - 주문이 만들어진 뒤 실제로 상품을 지급할 때 호출해요. * @property {(event: SubscriptionSuccessEvent) => void | Promise} onEvent - 결제가 성공했을 때 호출해요. * @property {(error: unknown) => void | Promise} onError - 결제 과정에서 에러가 발생했을 때 호출해요. */ interface CreateSubscriptionPurchaseOrderOptions { options: { sku: string; offerId?: string | null; processProductGrant: (params: { orderId: string; subscriptionId?: string; }) => boolean | Promise; }; onEvent: (event: SubscriptionSuccessEvent) => void | Promise; onError: (error: unknown) => void | Promise; } /** * @public * @category 인앱결제 * @name IapCreateSubscriptionPurchaseOrderResult * @description 구독 인앱결제가 완료되면 결제 세부 정보와 상품 정보를 담아 반환해요. `IapCreateOneTimePurchaseOrderResult`와 동일한 구조예요. */ type IapCreateSubscriptionPurchaseOrderResult = IapCreateOneTimePurchaseOrderResult; interface SubscriptionSuccessEvent { type: 'success'; data: IapCreateSubscriptionPurchaseOrderResult; } /** * @public * @category 인앱결제 * @name createSubscriptionPurchaseOrder * @description * 구독 인앱결제 주문서 페이지로 이동해요. 사용자가 구독 상품 구매 버튼을 누르는 상황 등에 사용할 수 있어요. * @param {CreateSubscriptionPurchaseOrderOptions} params - 구독 인앱결제를 생성할 때 필요한 정보예요. * @returns {() => void} 앱브릿지 cleanup 함수를 반환해요. 인앱결제 기능이 끝나면 반드시 이 함수를 호출해서 리소스를 해제해야 해요. * * @example * ### 구독 인앱결제 주문서 페이지로 이동하기 * * ```tsx * import { IAP } from "@apps-in-toss/web-framework"; * import { Button } from "@toss/tds-react-native"; * import { useCallback } from "react"; * * interface Props { * sku: string; * offerId?: string; * } * * function SubscriptionPurchaseButton({ sku, offerId }: Props) { * const handleClick = useCallback(async () => { * const cleanup = IAP.createSubscriptionPurchaseOrder({ * options: { * sku, * offerId, * processProductGrant: ({ orderId, subscriptionId }) => { * // 상품 지급 로직 작성 * return true; // 상품 지급 여부 * }, * }, * onEvent: (event) => { * console.log(event); * }, * onError: (error) => { * console.error(error); * }, * }); * * return cleanup; * }, [sku, offerId]); * * return ; * } * ``` */ declare function createSubscriptionPurchaseOrder(params: CreateSubscriptionPurchaseOrderOptions): () => void; /** * @public * @category 인앱결제 * @name IAP * @description 인앱결제 관련 기능을 모은 객체예요. 단건 인앱결제 주문서 이동과 상품 목록 조회 기능을 제공해요. * @property {typeof createOneTimePurchaseOrder} [createOneTimePurchaseOrder] 특정 인앱결제 주문서 페이지로 이동해요. 자세한 내용은 [createOneTimePurchaseOrder](https://developers-apps-in-toss.toss.im/bedrock/reference/framework/%EC%9D%B8%EC%95%B1%20%EA%B2%B0%EC%A0%9C/createOneTimePurchaseOrder.html) 문서를 참고하세요. * @property {typeof getProductItemList} [getProductItemList] 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 자세한 내용은 [getProductItemList](https://developers-apps-in-toss.toss.im/bedrock/reference/framework/%EC%9D%B8%EC%95%B1%20%EA%B2%B0%EC%A0%9C/getProductItemList.html) 문서를 참고하세요. * @property {typeof getPendingOrders} [getPendingOrders] 대기 중인 주문 목록을 가져와요. 자세한 내용은 [getPendingOrders](https://developers-apps-in-toss.toss.im/bedrock/reference/framework/%EC%9D%B8%EC%95%B1%20%EA%B2%B0%EC%A0%9C/getPendingOrders.htm) 문서를 참고하세요. * @property {typeof getCompletedOrRefundedOrders} [getCompletedOrRefundedOrders] 인앱결제로 구매하거나 환불한 주문 목록을 가져와요. 자세한 내용은 [getCompletedOrRefundedOrders](https://developers-apps-in-toss.toss.im/bedrock/reference/framework/%EC%9D%B8%EC%95%B1%20%EA%B2%B0%EC%A0%9C/getCompletedOrRefundedOrders.html) 문서를 참고하세요. * @property {typeof completeProductGrant} [completeProductGrant] 상품 지급 처리를 완료했다는 메시지를 앱에 전달해요. 자세한 내용은 [completeProductGrant](https://developers-apps-in-toss.toss.im/bedrock/reference/framework/%EC%9D%B8%EC%95%B1%20%EA%B2%B0%EC%A0%9C/completeProductGrant.html) 문서를 참고하세요. * @property {typeof getSubscriptionInfo} [getSubscriptionInfo] 구독 주문의 현재 상태 정보를 가져와요. */ declare const IAP: { createOneTimePurchaseOrder: typeof createOneTimePurchaseOrder; createSubscriptionPurchaseOrder: typeof createSubscriptionPurchaseOrder; getProductItemList: typeof getProductItemList; getPendingOrders: typeof getPendingOrders; getCompletedOrRefundedOrders: typeof getCompletedOrRefundedOrders; completeProductGrant: typeof completeProductGrant; getSubscriptionInfo: typeof getSubscriptionInfo; }; interface SaveBase64DataParams { data: string; fileName: string; mimeType: string; } /** * @public * @category 데이터 * @name saveBase64Data * @description 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요. * @param {SaveBase64DataParams} params - 저장할 데이터와 파일 정보를 담은 객체예요. * @param {string} params.data - Base64 형식으로 인코딩된 데이터 문자열이에요. * @param {string} params.fileName - 저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요. * @param {string} params.mimeType - 저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요. * * @example * ### Base64 이미지 데이터를 사용자 기기에 저장하기 * * ```tsx * import { Button } from 'react-native'; * import { saveBase64Data } from '@apps-in-toss/framework'; * * // '저장' 버튼을 누르면 이미지가 사용자 기기에 저장돼요. * function SaveButton() { * const handleSave = async () => { * try { * await saveBase64Data({ * data: 'iVBORw0KGgo...', * fileName: 'some-photo.png', * mimeType: 'image/png', * }); * } catch (error) { * console.error('데이터 저장에 실패했어요:', error); * } * }; * * return * ); * } * ``` */ declare function submitGameCenterLeaderBoardScore(params: { score: string; }): Promise; /** * Async Methods Map * Type definitions for all async methods accessed via postMessage */ interface AsyncMethodsMap { getStorageItem: (params: { key: string; }) => Promise; setStorageItem: (params: { key: string; value: string; }) => Promise; removeStorageItem: (params: { key: string; }) => Promise; clearStorage: (params: CompatiblePlaceholderArgument) => Promise; getPermission: (params: { name: PermissionName; access: PermissionAccess; }) => Promise; openPermissionDialog: (params: { name: PermissionName; access: PermissionAccess; }) => Promise<'allowed' | 'denied'>; getClipboardText: (params: CompatiblePlaceholderArgument) => Promise; setClipboardText: (params: { text: string; }) => Promise; fetchContacts: (params: { size: number; offset: number; query?: { contains?: string; }; }) => Promise; fetchAlbumPhotos: (params: { base64?: boolean; maxCount?: number; maxWidth?: number; }) => Promise; openCamera: (params: { base64?: boolean; maxWidth?: number; }) => Promise; startUpdateLocation: (params: { accuracy: number; timeInterval: number; distanceInterval: number; }) => Promise; getCurrentLocation: (params: { accuracy: number; }) => Promise; iapCreateOneTimePurchaseOrder: (params: { productId: string; }) => Promise; processProductGrant: (params: { orderId: string; isProductGranted: boolean; }) => Promise; iapGetProductItemList: (params: CompatiblePlaceholderArgument) => Promise<{ products: any[]; }>; getPendingOrders: (params: CompatiblePlaceholderArgument) => Promise<{ orders: Array<{ orderId: string; sku: string; }>; }>; getCompletedOrRefundedOrders: (params: { key?: string | null; }) => Promise; completeProductGrant: (params: { orderId: string; }) => Promise; getSubscriptionInfo: (params: { params: { orderId: string; }; }) => Promise<{ subscription: IapSubscriptionInfoResult; }>; eventLog: (params: { log_name: string; log_type: string; params: Record; }) => Promise; getTossShareLink: (params: CompatiblePlaceholderArgument) => Promise<{ shareLink: string; }>; appLogin: (params: CompatiblePlaceholderArgument) => Promise<{ authorizationCode: string; referrer: 'DEFAULT' | 'SANDBOX'; }>; checkoutPayment: (params: CheckoutPaymentOptions) => Promise; setDeviceOrientation: (params: { type: 'portrait' | 'landscape'; }) => Promise; saveBase64Data: (params: SaveBase64DataParams) => Promise; appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise; getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise; getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise; getUserKey: (params: CompatiblePlaceholderArgument) => Promise; grantPromotionRewardForGame: (params: { promotionCode: string; amount: number; }) => Promise; submitGameCenterLeaderBoardScore: (params: { score: string; }) => Promise; requestOneTimePurchase: (params: { sku: string; }) => Promise; contactsViral: (params: { moduleId: string; }) => Promise; getMiniAppsSupportContact: (params: object) => Promise; loadAdMobInterstitialAd: (params: { adUnitId: string; }) => Promise; showAdMobInterstitialAd: (params: { adUnitId: string; }) => Promise; loadAdMobRewardedAd: (params: { adUnitId: string; }) => Promise; showAdMobRewardedAd: (params: { adUnitId: string; }) => Promise; loadAppsInTossAdmob: (params: { adGroupId: string; referrer: string; }) => Promise; showAppsInTossAdmob: (params: { adGroupId: string; referrer: string; }) => Promise; getIsTossLoginIntegratedService: (params: object) => Promise; getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{ serverTime: number; }>; shareWithScheme: (params: { schemeURL: string; }) => Promise; requestMiniAppReview: (params: { title: string; }) => Promise; } /** * Sync Methods Map * Type definitions for all sync methods accessed via postMessageSync */ interface SyncMethodsMap { getWebBundleURL: (params: CompatiblePlaceholderArgument) => { url: string; }; stopUpdateLocation: (params: object) => void; } /** * Type-safe postMessage wrapper * Provides type inference for async method calls without requiring 'as unknown' casts */ declare function safePostMessage(method: K, params: Parameters[0]): ReturnType; /** * Type-safe postMessageSync wrapper * Provides type inference for sync method calls without requiring 'as unknown' casts */ declare function safeSyncPostMessage(method: K, params: Parameters[0]): ReturnType; interface EventEmitterSchema { name: K; params: P; } /** * @name UpdateLocationEventEmitter * @kind typedef * @description * 디바이스의 위치 정보 변경을 감지해요 */ type UpdateLocationEventEmitter = EventEmitterSchema<'updateLocation', [Location]>; /** * @public * @category 위치 정보 * @name startUpdateLocation * @description 디바이스의 위치 정보를 지속적으로 감지하고, 위치가 변경되면 콜백을 실행하는 함수예요. 콜백 함수를 등록하면 위치가 변경될 때마다 자동으로 호출돼요. * 실시간 위치 추적이 필요한 기능을 구현할 때 사용할 수 있어요. 예를 들어 지도 앱에서 사용자의 현재 위치를 실시간으로 업데이트할 때, 운동 앱에서 사용자의 이동 거리를 기록할 때 등이에요. * 위치 업데이트 주기와 정확도를 조정해 배터리 소모를 최소화하면서도 필요한 정보를 얻을 수 있어요. * * * @param {(error: unknown) => void} onError 위치 정보 감지에 실패했을 때 호출되는 콜백 함수예요. * @param {(location: Location) => void} onEvent 위치 정보가 변경될 때 호출되는 콜백 함수예요. 자세한 내용은 [Location](/react-native/reference/native-modules/Types/Location.html)을 참고해주세요. * @param {StartUpdateLocationOptions} options - 위치 정보 감지에 필요한 설정 객체에요. * @param {number} [options.accuracy] 위치 정확도를 설정해요. * @param {number} [options.timeInterval] 위치 정보를 업데이트하는 최소 주기로, 단위는 밀리초(ms)예요. 이 값은 위치 업데이트가 발생하는 가장 짧은 간격을 설정하지만, 시스템이나 환경의 영향을 받아 지정한 주기보다 더 긴 간격으로 업데이트될 수 있어요. * @param {number} [options.distanceInterval] 위치 변경 거리를 미터(m) 단위로 설정해요. * * @property [openPermissionDialog] - 위치 정보 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요. * @property [getPermission] - 위치 정보 권한의 현재 상태를 반환해요. `allowed`는 사용자가 위치 정보 권한을 허용한 상태예요. `denied`는 사용자가 위치 정보 권한을 거부한 상태예요. `notDetermined`는 위치 정보 권한 요청을 한 번도 하지 않은 상태예요. * * @signature * ```typescript * function startUpdateLocation(options: { * onError: (error: unknown) => void; * onEvent: (location: Location) => void; * options: StartUpdateLocationOptions; * }): () => void; * ``` * * @example * ### 위치 정보 변경 감지하기 * * 위치 정보가 변경되는것을 감지하는 예제예요. "위치 정보 변경 감지하기"를 눌러서 감지할 수 있어요. * * "권한 확인하기"버튼을 눌러서 현재 위치 정보 변경 감지 권한을 확인해요. * 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`StartUpdateLocationPermissionError`](/react-native/reference/types/권한/StartUpdateLocationPermissionError)를 반환해요. * "권한 요청하기"버튼을 눌러서 위치 정보 변경 감지 권한을 요청할 수 있어요. * * ```tsx * import { Accuracy, Location, startUpdateLocation, StartUpdateLocationPermissionError } from '@apps-in-toss/framework'; * import { useCallback, useState } from 'react'; * import { Alert, Button, Text, View } from 'react-native'; * * // 위치 정보 변경 감지하기 * function LocationWatcher() { * const [location, setLocation] = useState(null); * * const handlePress = useCallback(() => { * startUpdateLocation({ * options: { * accuracy: Accuracy.Balanced, * timeInterval: 3000, * distanceInterval: 10, * }, * onEvent: (location) => { * setLocation(location); * }, * onError: (error) => { * if (error instanceof StartUpdateLocationPermissionError) { * // 위치 정보 변경 감지 권한 없음 * } * console.error('위치 정보를 가져오는데 실패했어요:', error); * }, * }); * }, []); * * return ( * * {location != null && ( * <> * 위도: {location.coords.latitude} * 경도: {location.coords.longitude} * 위치 정확도: {location.coords.accuracy}m * 높이: {location.coords.altitude}m * 고도 정확도: {location.coords.altitudeAccuracy}m * 방향: {location.coords.heading}° * * )} * * * ); * } * ``` */ declare function grantPromotionReward(params: { params: { promotionCode: string; amount: number; }; }): Promise; /** * @public * @category 토스 로그인 * @name getIsTossLoginIntegratedService * @description * 유저가 토스 로그인을 연동했는지 여부를 확인해요. * 기존 토스 로그인 사용자를 찾아서 게임 식별자로 전환하는 마이그레이션을 할 때 사용할 수 있어요. * @returns {Promise} * 토스 로그인이 연동된 유저인지 여부를 반환해요. * - `true`: 토스 로그인이 연동된 유저에요. * - `false`: 토스 로그인이 연동되지 않은 유저에요. * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요. * @throw {message: "oauth2ClientId 설정이 필요합니다."} - 토스 로그인을 사용하지 않는 미니앱에서 호출했을 때 발생해요. * @example * ```tsx * // react-native * import { Button } from 'react-native'; * import { getIsTossLoginIntegratedService } from '@apps-in-toss/framework'; * * function GetIsTossLoginIntegratedServiceButton() { * async function handlePress() { * try { * const result = await getIsTossLoginIntegratedService(); * * if (result === undefined) { * console.warn('지원하지 않는 앱 버전이에요.'); * return; * } * if (result === true) { * console.log('토스 로그인이 연동된 유저에요.'); * // 여기에서 토스 로그인 연동 유저에 대한 처리를 할 수 있어요. * } * if (result === false) { * console.log('토스 로그인이 연동되지 않은 유저에요.'); * // 여기에서 토스 로그인 연동 유저가 아닌 경우에 대한 처리를 할 수 있어요. * } * } catch (error) { * console.error(error); * } * } * * return ( *