@apps-in-toss/native-modules 2.4.7 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,6 +87,10 @@
87
87
  "identifier": "checkoutPayment",
88
88
  "dts": "/**\n * @public\n * @category 토스페이\n * @name CheckoutPaymentOptions\n * @description 토스페이 결제창을 띄울 때 필요한 옵션이에요.\n * @property {string} payToken 결제 토큰이에요.\n */\nexport interface CheckoutPaymentOptions {\n\t/**\n\t * 결제 토큰이에요.\n\t */\n\tpayToken: string;\n}\n/**\n * @public\n * @category 토스페이\n * @name CheckoutPaymentResult\n * @description 토스페이 결제창에서 사용자가 인증에 성공했는지 여부예요.\n * @property {boolean} success 인증이 성공했는지 여부예요.\n * @property {string} [reason] 인증이 실패했을 경우의 이유예요.\n */\nexport interface CheckoutPaymentResult {\n\t/**\n\t * 인증이 성공했는지 여부예요.\n\t */\n\tsuccess: boolean;\n\t/**\n\t * 인증이 실패했을 경우의 이유예요.\n\t */\n\treason?: string;\n}\n/**\n * @public\n * @category 토스페이\n * @name checkoutPayment\n * @description 토스페이 결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.\n *\n * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.\n *\n * @param {CheckoutPaymentOptions} options 결제창을 띄울 때 필요한 옵션이에요.\n * @returns {Promise<CheckoutPaymentResult>} 인증 성공 여부를 포함한 결과를 반환해요.\n *\n * @example\n *\n * ### 토스페이 결제창 띄우고 인증 처리하기\n *\n * ```tsx\n * import { TossPay } from '@apps-in-toss/framework';\n *\n * async function handlePayment() {\n * try {\n * // 실제 구현 시 결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.\n * const { payToken } = await fetch('/my-api/payment/create').then(res => res.json());\n *\n * const { success, reason } = await TossPay.checkoutPayment({ payToken });\n *\n * if (success) {\n * // 실제 구현 시 결제를 실행하는 API 엔드포인트로 대체해주세요.\n * await fetch('/my-api/payment/execute', {\n * method: 'POST',\n * body: JSON.stringify({ payToken }),\n * headers: { 'Content-Type': 'application/json' },\n * });\n * } else {\n * console.log('인증 실패:', reason);\n * }\n * } catch (error) {\n * console.error('결제 인증 중 오류가 발생했어요:', error);\n * }\n * }\n * ```\n */\nexport declare function checkoutPayment(options: {\n\tparams: CheckoutPaymentOptions;\n}): Promise<CheckoutPaymentResult>;\n\nexport {};\n"
89
89
  },
90
+ {
91
+ "identifier": "requestTossPayPaysBilling",
92
+ "dts": "/**\n * @public\n * @category 토스페이\n * @name RequestTossPayPaysBillingOptions\n * @description 토스페이 정기결제창을 띄울 때 필요한 옵션이에요.\n * @property {string} wrappedToken 정기결제 래핑 토큰이에요.\n */\nexport interface RequestTossPayPaysBillingOptions {\n\t/**\n\t * 정기결제 래핑 토큰이에요.\n\t */\n\twrappedToken: string;\n}\n/**\n * @public\n * @category 토스페이\n * @name RequestTossPayPaysBillingResult\n * @description 토스페이 정기결제창에서 사용자가 인증에 성공했는지 여부예요.\n * @property {boolean} success 인증이 성공했는지 여부예요.\n * @property {string} [reason] 인증이 실패했을 경우의 이유예요.\n */\nexport interface RequestTossPayPaysBillingResult {\n\t/**\n\t * 인증이 성공했는지 여부예요.\n\t */\n\tsuccess: boolean;\n\t/**\n\t * 인증이 실패했을 경우의 이유예요.\n\t */\n\treason?: string;\n}\n/**\n * @public\n * @category 토스페이\n * @name requestTossPayPaysBilling\n * @description 토스페이 정기결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.\n *\n * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.\n *\n * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.\n * @param {RequestTossPayPaysBillingOptions} options 정기결제창을 띄울 때 필요한 옵션이에요.\n * @returns {Promise<RequestTossPayPaysBillingResult>} 인증 성공 여부를 포함한 결과를 반환해요.\n *\n * @example\n *\n * ### 토스페이 정기결제창 띄우고 인증 처리하기\n *\n * ```tsx\n * import { TossPay } from '@apps-in-toss/framework';\n *\n * async function handleBilling() {\n * try {\n * // 실제 구현 시 정기결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.\n * const { wrappedToken } = await fetch('/my-api/billing/create').then(res => res.json());\n *\n * const { success, reason } = await TossPay.requestTossPayPaysBilling({ wrappedToken });\n *\n * if (success) {\n * // 실제 구현 시 정기결제를 실행하는 API 엔드포인트로 대체해주세요.\n * await fetch('/my-api/billing/execute', {\n * method: 'POST',\n * body: JSON.stringify({ wrappedToken }),\n * headers: { 'Content-Type': 'application/json' },\n * });\n * } else {\n * console.log('인증 실패:', reason);\n * }\n * } catch (error) {\n * console.error('정기결제 인증 중 오류가 발생했어요:', error);\n * }\n * }\n * ```\n */\nexport declare function requestTossPayPaysBilling(options: {\n\tparams: RequestTossPayPaysBillingOptions;\n}): Promise<RequestTossPayPaysBillingResult | undefined>;\nexport declare namespace requestTossPayPaysBilling {\n\tvar isSupported: () => boolean;\n}\n\nexport {};\n"
93
+ },
90
94
  {
91
95
  "identifier": "saveBase64Data",
92
96
  "dts": "export interface SaveBase64DataParams {\n\tdata: string;\n\tfileName: string;\n\tmimeType: string;\n}\n/**\n * @public\n * @category 데이터\n * @name saveBase64Data\n * @description 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요.\n * @param {SaveBase64DataParams} params - 저장할 데이터와 파일 정보를 담은 객체예요.\n * @param {string} params.data - Base64 형식으로 인코딩된 데이터 문자열이에요.\n * @param {string} params.fileName - 저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요.\n * @param {string} params.mimeType - 저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요.\n *\n * @example\n * ### Base64 이미지 데이터를 사용자 기기에 저장하기\n *\n * ```tsx\n * import { Button } from 'react-native';\n * import { saveBase64Data } from '@apps-in-toss/framework';\n *\n * // '저장' 버튼을 누르면 이미지가 사용자 기기에 저장돼요.\n * function SaveButton() {\n * const handleSave = async () => {\n * try {\n * await saveBase64Data({\n * data: 'iVBORw0KGgo...',\n * fileName: 'some-photo.png',\n * mimeType: 'image/png',\n * });\n * } catch (error) {\n * console.error('데이터 저장에 실패했어요:', error);\n * }\n * };\n *\n * return <Button title=\"저장\" onPress={handleSave} />;\n * }\n * ```\n */\nexport declare function saveBase64Data(params: SaveBase64DataParams): Promise<void>;\n\nexport {};\n"
package/dist/index.cjs CHANGED
@@ -62,8 +62,10 @@ __export(index_exports, {
62
62
  openGameCenterLeaderboard: () => openGameCenterLeaderboard,
63
63
  openURL: () => openURL2,
64
64
  processProductGrant: () => processProductGrant,
65
+ requestNotificationAgreement: () => requestNotificationAgreement,
65
66
  requestOneTimePurchase: () => requestOneTimePurchase,
66
67
  requestReview: () => requestReview,
68
+ requestTossPayPaysBilling: () => requestTossPayPaysBilling,
67
69
  safePostMessage: () => safePostMessage,
68
70
  safeSyncPostMessage: () => safeSyncPostMessage,
69
71
  saveBase64Data: () => saveBase64Data,
@@ -492,6 +494,17 @@ async function checkoutPayment(options) {
492
494
  return safePostMessage("checkoutPayment", options.params);
493
495
  }
494
496
 
497
+ // src/MiniAppModule/native-modules/requestTossPayPaysBilling.ts
498
+ var MIN_VERSION = { android: "5.256.0", ios: "5.256.0" };
499
+ async function requestTossPayPaysBilling(options) {
500
+ if (!requestTossPayPaysBilling.isSupported()) {
501
+ console.warn("requestTossPayPaysBilling is not supported in this app version");
502
+ return;
503
+ }
504
+ return safePostMessage("requestTossPayPaysBilling", options.params);
505
+ }
506
+ requestTossPayPaysBilling.isSupported = () => isMinVersionSupported(MIN_VERSION);
507
+
495
508
  // src/MiniAppModule/native-modules/appLogin.ts
496
509
  async function appLogin() {
497
510
  return safePostMessage("appLogin", {});
@@ -1062,7 +1075,7 @@ async function getServerTime() {
1062
1075
  getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
1063
1076
 
1064
1077
  // src/MiniAppModule/native-modules/requestReview.ts
1065
- var MIN_VERSION = { android: "5.253.0", ios: "5.253.0" };
1078
+ var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
1066
1079
  async function requestReview() {
1067
1080
  const isSupported = requestReview.isSupported();
1068
1081
  if (!isSupported) {
@@ -1074,11 +1087,33 @@ async function requestReview() {
1074
1087
  }
1075
1088
  return safePostMessage("requestMiniAppReview", { title: brandDisplayName });
1076
1089
  }
1077
- requestReview.isSupported = () => isMinVersionSupported(MIN_VERSION);
1090
+ requestReview.isSupported = () => isMinVersionSupported(MIN_VERSION2);
1091
+
1092
+ // src/MiniAppModule/native-modules/requestNotificationAgreement.ts
1093
+ var import_es_toolkit3 = require("es-toolkit");
1094
+ var MIN_VERSION3 = { android: "5.255.0", ios: "5.255.0" };
1095
+ function isRequestNotificationAgreementSupported() {
1096
+ return isMinVersionSupported(MIN_VERSION3);
1097
+ }
1098
+ function requestNotificationAgreement(params) {
1099
+ if (!isRequestNotificationAgreementSupported()) {
1100
+ return import_es_toolkit3.noop;
1101
+ }
1102
+ const { options, onEvent, onError } = params;
1103
+ return INTERNAL__appBridgeHandler.invokeAppBridgeMethod("requestNotificationAgreement", options, {
1104
+ onSuccess: (result) => {
1105
+ onEvent({ type: result.agreementResult });
1106
+ },
1107
+ onError: (error) => {
1108
+ onError(error);
1109
+ }
1110
+ });
1111
+ }
1078
1112
 
1079
1113
  // src/MiniAppModule/native-modules/index.ts
1080
1114
  var TossPay = {
1081
- checkoutPayment
1115
+ checkoutPayment,
1116
+ requestTossPayPaysBilling
1082
1117
  };
1083
1118
  var GoogleAdMob = {
1084
1119
  loadAppsInTossAdMob,
@@ -1234,8 +1269,10 @@ var INTERNAL__module = {
1234
1269
  openGameCenterLeaderboard,
1235
1270
  openURL,
1236
1271
  processProductGrant,
1272
+ requestNotificationAgreement,
1237
1273
  requestOneTimePurchase,
1238
1274
  requestReview,
1275
+ requestTossPayPaysBilling,
1239
1276
  safePostMessage,
1240
1277
  safeSyncPostMessage,
1241
1278
  saveBase64Data,
package/dist/index.d.cts CHANGED
@@ -902,6 +902,137 @@ declare const IAP: {
902
902
  getSubscriptionInfo: typeof getSubscriptionInfo;
903
903
  };
904
904
 
905
+ /**
906
+ * @public
907
+ * @category 알림
908
+ * @name NotificationAgreementResult
909
+ * @description 푸시 알림 동의 플로우의 결과예요.
910
+ * @property {'newAgreement'} newAgreement - 이번에 새로 동의한 경우예요.
911
+ * @property {'alreadyAgreed'} alreadyAgreed - 이미 동의한 사용자인 경우예요.
912
+ * @property {'agreementRejected'} agreementRejected - 사용자가 동의를 거부한 경우예요.
913
+ */
914
+ type NotificationAgreementResult = 'newAgreement' | 'alreadyAgreed' | 'agreementRejected';
915
+ /**
916
+ * @property {string} templateCode - 알림 동의를 받을 스마트발송 캠패인의 템플릿 코드예요. 코드는 앱인토스 콘솔 > 미니앱 > 스마트발송에서 작성한 값을 입력해주세요.
917
+ * @property {(result: { type: NotificationAgreementResult }) => void} onEvent - 알림 동의 결과를 콜백으로 전달해요.
918
+ * @property {(error: unknown) => void | Promise<void>} onError - 알림 동의 요청 시 에러가 발생하면 콜백으로 전달해요.
919
+ */
920
+ interface RequestNotificationAgreementOptions {
921
+ options: {
922
+ templateCode: string;
923
+ };
924
+ onEvent: (result: {
925
+ type: NotificationAgreementResult;
926
+ }) => void;
927
+ onError: (error: unknown) => void | Promise<void>;
928
+ }
929
+ /**
930
+ * @public
931
+ * @category 알림
932
+ * @name requestNotificationAgreement
933
+ * @description 알림 동의 화면을 요청하고, 동의 결과를 콜백으로 전달해요.
934
+ * @param {RequestNotificationAgreementOptions} params - 템플릿 코드와 콜백이에요.
935
+ * @returns {() => void} 앱브릿지 콜백을 해제하는 함수예요.
936
+ *
937
+ * @example
938
+ * ```ts
939
+ * import { requestNotificationAgreement } from '@apps-in-toss/framework';
940
+ *
941
+ * const cleanup = requestNotificationAgreement({
942
+ * options: { templateCode: 'test-template-code' },
943
+ * onEvent: (result) => {
944
+ * console.log(result);
945
+ * cleanup();
946
+ * },
947
+ * onError: (error) => {
948
+ * console.error(error);
949
+ * cleanup();
950
+ * },
951
+ * });
952
+ * ```
953
+ */
954
+ declare function requestNotificationAgreement(params: RequestNotificationAgreementOptions): () => void;
955
+
956
+ /**
957
+ * @public
958
+ * @category 토스페이
959
+ * @name RequestTossPayPaysBillingOptions
960
+ * @description 토스페이 정기결제창을 띄울 때 필요한 옵션이에요.
961
+ * @property {string} wrappedToken 정기결제 래핑 토큰이에요.
962
+ */
963
+ interface RequestTossPayPaysBillingOptions {
964
+ /**
965
+ * 정기결제 래핑 토큰이에요.
966
+ */
967
+ wrappedToken: string;
968
+ }
969
+ /**
970
+ * @public
971
+ * @category 토스페이
972
+ * @name RequestTossPayPaysBillingResult
973
+ * @description 토스페이 정기결제창에서 사용자가 인증에 성공했는지 여부예요.
974
+ * @property {boolean} success 인증이 성공했는지 여부예요.
975
+ * @property {string} [reason] 인증이 실패했을 경우의 이유예요.
976
+ */
977
+ interface RequestTossPayPaysBillingResult {
978
+ /**
979
+ * 인증이 성공했는지 여부예요.
980
+ */
981
+ success: boolean;
982
+ /**
983
+ * 인증이 실패했을 경우의 이유예요.
984
+ */
985
+ reason?: string;
986
+ }
987
+ /**
988
+ * @public
989
+ * @category 토스페이
990
+ * @name requestTossPayPaysBilling
991
+ * @description 토스페이 정기결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.
992
+ *
993
+ * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.
994
+ *
995
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
996
+ * @param {RequestTossPayPaysBillingOptions} options 정기결제창을 띄울 때 필요한 옵션이에요.
997
+ * @returns {Promise<RequestTossPayPaysBillingResult>} 인증 성공 여부를 포함한 결과를 반환해요.
998
+ *
999
+ * @example
1000
+ *
1001
+ * ### 토스페이 정기결제창 띄우고 인증 처리하기
1002
+ *
1003
+ * ```tsx
1004
+ * import { TossPay } from '@apps-in-toss/framework';
1005
+ *
1006
+ * async function handleBilling() {
1007
+ * try {
1008
+ * // 실제 구현 시 정기결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.
1009
+ * const { wrappedToken } = await fetch('/my-api/billing/create').then(res => res.json());
1010
+ *
1011
+ * const { success, reason } = await TossPay.requestTossPayPaysBilling({ wrappedToken });
1012
+ *
1013
+ * if (success) {
1014
+ * // 실제 구현 시 정기결제를 실행하는 API 엔드포인트로 대체해주세요.
1015
+ * await fetch('/my-api/billing/execute', {
1016
+ * method: 'POST',
1017
+ * body: JSON.stringify({ wrappedToken }),
1018
+ * headers: { 'Content-Type': 'application/json' },
1019
+ * });
1020
+ * } else {
1021
+ * console.log('인증 실패:', reason);
1022
+ * }
1023
+ * } catch (error) {
1024
+ * console.error('정기결제 인증 중 오류가 발생했어요:', error);
1025
+ * }
1026
+ * }
1027
+ * ```
1028
+ */
1029
+ declare function requestTossPayPaysBilling(options: {
1030
+ params: RequestTossPayPaysBillingOptions;
1031
+ }): Promise<RequestTossPayPaysBillingResult | undefined>;
1032
+ declare namespace requestTossPayPaysBilling {
1033
+ var isSupported: () => boolean;
1034
+ }
1035
+
905
1036
  interface SaveBase64DataParams {
906
1037
  data: string;
907
1038
  fileName: string;
@@ -1101,6 +1232,7 @@ interface AsyncMethodsMap {
1101
1232
  referrer: 'DEFAULT' | 'SANDBOX';
1102
1233
  }>;
1103
1234
  checkoutPayment: (params: CheckoutPaymentOptions) => Promise<CheckoutPaymentResult>;
1235
+ requestTossPayPaysBilling: (params: RequestTossPayPaysBillingOptions) => Promise<RequestTossPayPaysBillingResult>;
1104
1236
  setDeviceOrientation: (params: {
1105
1237
  type: 'portrait' | 'landscape';
1106
1238
  }) => Promise<void>;
@@ -1153,6 +1285,7 @@ interface AsyncMethodsMap {
1153
1285
  requestMiniAppReview: (params: {
1154
1286
  title: string;
1155
1287
  }) => Promise<void>;
1288
+ requestNotificationAgreement: (params: RequestNotificationAgreementOptions) => Promise<void>;
1156
1289
  }
1157
1290
  /**
1158
1291
  * Sync Methods Map
@@ -2864,9 +2997,11 @@ declare namespace requestReview {
2864
2997
  * @name TossPay
2865
2998
  * @description 토스페이 결제 관련 함수를 모아둔 객체예요.
2866
2999
  * @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 인증하는 함수예요. 자세한 내용은 [checkoutPayment](/react-native/reference/native-modules/토스페이/checkoutPayment)를 참고하세요.
3000
+ * @property {typeof requestTossPayPaysBilling} [requestTossPayPaysBilling] 토스페이 정기결제를 인증하는 함수예요. 자세한 내용은 [requestTossPayPaysBilling](/react-native/reference/native-modules/토스페이/requestTossPayPaysBilling)를 참고하세요.
2867
3001
  */
2868
3002
  declare const TossPay: {
2869
3003
  checkoutPayment: typeof checkoutPayment;
3004
+ requestTossPayPaysBilling: typeof requestTossPayPaysBilling;
2870
3005
  };
2871
3006
 
2872
3007
  /**
@@ -3315,4 +3450,4 @@ declare const INTERNAL__module: {
3315
3450
  tossCoreEventLog: typeof tossCoreEventLog;
3316
3451
  };
3317
3452
 
3318
- export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
3453
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.d.ts CHANGED
@@ -902,6 +902,137 @@ declare const IAP: {
902
902
  getSubscriptionInfo: typeof getSubscriptionInfo;
903
903
  };
904
904
 
905
+ /**
906
+ * @public
907
+ * @category 알림
908
+ * @name NotificationAgreementResult
909
+ * @description 푸시 알림 동의 플로우의 결과예요.
910
+ * @property {'newAgreement'} newAgreement - 이번에 새로 동의한 경우예요.
911
+ * @property {'alreadyAgreed'} alreadyAgreed - 이미 동의한 사용자인 경우예요.
912
+ * @property {'agreementRejected'} agreementRejected - 사용자가 동의를 거부한 경우예요.
913
+ */
914
+ type NotificationAgreementResult = 'newAgreement' | 'alreadyAgreed' | 'agreementRejected';
915
+ /**
916
+ * @property {string} templateCode - 알림 동의를 받을 스마트발송 캠패인의 템플릿 코드예요. 코드는 앱인토스 콘솔 > 미니앱 > 스마트발송에서 작성한 값을 입력해주세요.
917
+ * @property {(result: { type: NotificationAgreementResult }) => void} onEvent - 알림 동의 결과를 콜백으로 전달해요.
918
+ * @property {(error: unknown) => void | Promise<void>} onError - 알림 동의 요청 시 에러가 발생하면 콜백으로 전달해요.
919
+ */
920
+ interface RequestNotificationAgreementOptions {
921
+ options: {
922
+ templateCode: string;
923
+ };
924
+ onEvent: (result: {
925
+ type: NotificationAgreementResult;
926
+ }) => void;
927
+ onError: (error: unknown) => void | Promise<void>;
928
+ }
929
+ /**
930
+ * @public
931
+ * @category 알림
932
+ * @name requestNotificationAgreement
933
+ * @description 알림 동의 화면을 요청하고, 동의 결과를 콜백으로 전달해요.
934
+ * @param {RequestNotificationAgreementOptions} params - 템플릿 코드와 콜백이에요.
935
+ * @returns {() => void} 앱브릿지 콜백을 해제하는 함수예요.
936
+ *
937
+ * @example
938
+ * ```ts
939
+ * import { requestNotificationAgreement } from '@apps-in-toss/framework';
940
+ *
941
+ * const cleanup = requestNotificationAgreement({
942
+ * options: { templateCode: 'test-template-code' },
943
+ * onEvent: (result) => {
944
+ * console.log(result);
945
+ * cleanup();
946
+ * },
947
+ * onError: (error) => {
948
+ * console.error(error);
949
+ * cleanup();
950
+ * },
951
+ * });
952
+ * ```
953
+ */
954
+ declare function requestNotificationAgreement(params: RequestNotificationAgreementOptions): () => void;
955
+
956
+ /**
957
+ * @public
958
+ * @category 토스페이
959
+ * @name RequestTossPayPaysBillingOptions
960
+ * @description 토스페이 정기결제창을 띄울 때 필요한 옵션이에요.
961
+ * @property {string} wrappedToken 정기결제 래핑 토큰이에요.
962
+ */
963
+ interface RequestTossPayPaysBillingOptions {
964
+ /**
965
+ * 정기결제 래핑 토큰이에요.
966
+ */
967
+ wrappedToken: string;
968
+ }
969
+ /**
970
+ * @public
971
+ * @category 토스페이
972
+ * @name RequestTossPayPaysBillingResult
973
+ * @description 토스페이 정기결제창에서 사용자가 인증에 성공했는지 여부예요.
974
+ * @property {boolean} success 인증이 성공했는지 여부예요.
975
+ * @property {string} [reason] 인증이 실패했을 경우의 이유예요.
976
+ */
977
+ interface RequestTossPayPaysBillingResult {
978
+ /**
979
+ * 인증이 성공했는지 여부예요.
980
+ */
981
+ success: boolean;
982
+ /**
983
+ * 인증이 실패했을 경우의 이유예요.
984
+ */
985
+ reason?: string;
986
+ }
987
+ /**
988
+ * @public
989
+ * @category 토스페이
990
+ * @name requestTossPayPaysBilling
991
+ * @description 토스페이 정기결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.
992
+ *
993
+ * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.
994
+ *
995
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
996
+ * @param {RequestTossPayPaysBillingOptions} options 정기결제창을 띄울 때 필요한 옵션이에요.
997
+ * @returns {Promise<RequestTossPayPaysBillingResult>} 인증 성공 여부를 포함한 결과를 반환해요.
998
+ *
999
+ * @example
1000
+ *
1001
+ * ### 토스페이 정기결제창 띄우고 인증 처리하기
1002
+ *
1003
+ * ```tsx
1004
+ * import { TossPay } from '@apps-in-toss/framework';
1005
+ *
1006
+ * async function handleBilling() {
1007
+ * try {
1008
+ * // 실제 구현 시 정기결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.
1009
+ * const { wrappedToken } = await fetch('/my-api/billing/create').then(res => res.json());
1010
+ *
1011
+ * const { success, reason } = await TossPay.requestTossPayPaysBilling({ wrappedToken });
1012
+ *
1013
+ * if (success) {
1014
+ * // 실제 구현 시 정기결제를 실행하는 API 엔드포인트로 대체해주세요.
1015
+ * await fetch('/my-api/billing/execute', {
1016
+ * method: 'POST',
1017
+ * body: JSON.stringify({ wrappedToken }),
1018
+ * headers: { 'Content-Type': 'application/json' },
1019
+ * });
1020
+ * } else {
1021
+ * console.log('인증 실패:', reason);
1022
+ * }
1023
+ * } catch (error) {
1024
+ * console.error('정기결제 인증 중 오류가 발생했어요:', error);
1025
+ * }
1026
+ * }
1027
+ * ```
1028
+ */
1029
+ declare function requestTossPayPaysBilling(options: {
1030
+ params: RequestTossPayPaysBillingOptions;
1031
+ }): Promise<RequestTossPayPaysBillingResult | undefined>;
1032
+ declare namespace requestTossPayPaysBilling {
1033
+ var isSupported: () => boolean;
1034
+ }
1035
+
905
1036
  interface SaveBase64DataParams {
906
1037
  data: string;
907
1038
  fileName: string;
@@ -1101,6 +1232,7 @@ interface AsyncMethodsMap {
1101
1232
  referrer: 'DEFAULT' | 'SANDBOX';
1102
1233
  }>;
1103
1234
  checkoutPayment: (params: CheckoutPaymentOptions) => Promise<CheckoutPaymentResult>;
1235
+ requestTossPayPaysBilling: (params: RequestTossPayPaysBillingOptions) => Promise<RequestTossPayPaysBillingResult>;
1104
1236
  setDeviceOrientation: (params: {
1105
1237
  type: 'portrait' | 'landscape';
1106
1238
  }) => Promise<void>;
@@ -1153,6 +1285,7 @@ interface AsyncMethodsMap {
1153
1285
  requestMiniAppReview: (params: {
1154
1286
  title: string;
1155
1287
  }) => Promise<void>;
1288
+ requestNotificationAgreement: (params: RequestNotificationAgreementOptions) => Promise<void>;
1156
1289
  }
1157
1290
  /**
1158
1291
  * Sync Methods Map
@@ -2864,9 +2997,11 @@ declare namespace requestReview {
2864
2997
  * @name TossPay
2865
2998
  * @description 토스페이 결제 관련 함수를 모아둔 객체예요.
2866
2999
  * @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 인증하는 함수예요. 자세한 내용은 [checkoutPayment](/react-native/reference/native-modules/토스페이/checkoutPayment)를 참고하세요.
3000
+ * @property {typeof requestTossPayPaysBilling} [requestTossPayPaysBilling] 토스페이 정기결제를 인증하는 함수예요. 자세한 내용은 [requestTossPayPaysBilling](/react-native/reference/native-modules/토스페이/requestTossPayPaysBilling)를 참고하세요.
2867
3001
  */
2868
3002
  declare const TossPay: {
2869
3003
  checkoutPayment: typeof checkoutPayment;
3004
+ requestTossPayPaysBilling: typeof requestTossPayPaysBilling;
2870
3005
  };
2871
3006
 
2872
3007
  /**
@@ -3315,4 +3450,4 @@ declare const INTERNAL__module: {
3315
3450
  tossCoreEventLog: typeof tossCoreEventLog;
3316
3451
  };
3317
3452
 
3318
- export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type Primitive, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, requestReview, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
3453
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetAnonymousKeyResponse, type GetAnonymousKeySuccessResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardErrorResponse, type GrantPromotionRewardErrorResult, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type GrantPromotionRewardResponse, type GrantPromotionRewardSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, type IapSubscriptionInfoResult, type NetworkStatus, type NonConsumableProductListItem, type NotificationAgreementResult, type Primitive, type RequestNotificationAgreementOptions, type RequestTossPayPaysBillingOptions, type RequestTossPayPaysBillingResult, type SaveBase64DataParams, Storage, type SubmitGameCenterLeaderBoardScoreResponse, type SubscriptionProductListItem, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, checkoutPayment, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getAnonymousKey, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionReward, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestNotificationAgreement, requestOneTimePurchase, requestReview, requestTossPayPaysBilling, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.js CHANGED
@@ -411,6 +411,17 @@ async function checkoutPayment(options) {
411
411
  return safePostMessage("checkoutPayment", options.params);
412
412
  }
413
413
 
414
+ // src/MiniAppModule/native-modules/requestTossPayPaysBilling.ts
415
+ var MIN_VERSION = { android: "5.256.0", ios: "5.256.0" };
416
+ async function requestTossPayPaysBilling(options) {
417
+ if (!requestTossPayPaysBilling.isSupported()) {
418
+ console.warn("requestTossPayPaysBilling is not supported in this app version");
419
+ return;
420
+ }
421
+ return safePostMessage("requestTossPayPaysBilling", options.params);
422
+ }
423
+ requestTossPayPaysBilling.isSupported = () => isMinVersionSupported(MIN_VERSION);
424
+
414
425
  // src/MiniAppModule/native-modules/appLogin.ts
415
426
  async function appLogin() {
416
427
  return safePostMessage("appLogin", {});
@@ -981,7 +992,7 @@ async function getServerTime() {
981
992
  getServerTime.isSupported = () => isMinVersionSupported(GET_SERVER_TIME_MIN_VERSION);
982
993
 
983
994
  // src/MiniAppModule/native-modules/requestReview.ts
984
- var MIN_VERSION = { android: "5.253.0", ios: "5.253.0" };
995
+ var MIN_VERSION2 = { android: "5.253.0", ios: "5.253.0" };
985
996
  async function requestReview() {
986
997
  const isSupported = requestReview.isSupported();
987
998
  if (!isSupported) {
@@ -993,11 +1004,33 @@ async function requestReview() {
993
1004
  }
994
1005
  return safePostMessage("requestMiniAppReview", { title: brandDisplayName });
995
1006
  }
996
- requestReview.isSupported = () => isMinVersionSupported(MIN_VERSION);
1007
+ requestReview.isSupported = () => isMinVersionSupported(MIN_VERSION2);
1008
+
1009
+ // src/MiniAppModule/native-modules/requestNotificationAgreement.ts
1010
+ import { noop as noop3 } from "es-toolkit";
1011
+ var MIN_VERSION3 = { android: "5.255.0", ios: "5.255.0" };
1012
+ function isRequestNotificationAgreementSupported() {
1013
+ return isMinVersionSupported(MIN_VERSION3);
1014
+ }
1015
+ function requestNotificationAgreement(params) {
1016
+ if (!isRequestNotificationAgreementSupported()) {
1017
+ return noop3;
1018
+ }
1019
+ const { options, onEvent, onError } = params;
1020
+ return INTERNAL__appBridgeHandler.invokeAppBridgeMethod("requestNotificationAgreement", options, {
1021
+ onSuccess: (result) => {
1022
+ onEvent({ type: result.agreementResult });
1023
+ },
1024
+ onError: (error) => {
1025
+ onError(error);
1026
+ }
1027
+ });
1028
+ }
997
1029
 
998
1030
  // src/MiniAppModule/native-modules/index.ts
999
1031
  var TossPay = {
1000
- checkoutPayment
1032
+ checkoutPayment,
1033
+ requestTossPayPaysBilling
1001
1034
  };
1002
1035
  var GoogleAdMob = {
1003
1036
  loadAppsInTossAdMob,
@@ -1152,8 +1185,10 @@ export {
1152
1185
  openGameCenterLeaderboard,
1153
1186
  openURL2 as openURL,
1154
1187
  processProductGrant,
1188
+ requestNotificationAgreement,
1155
1189
  requestOneTimePurchase,
1156
1190
  requestReview,
1191
+ requestTossPayPaysBilling,
1157
1192
  safePostMessage,
1158
1193
  safeSyncPostMessage,
1159
1194
  saveBase64Data,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/native-modules",
3
3
  "type": "module",
4
- "version": "2.4.7",
4
+ "version": "2.5.0",
5
5
  "description": "Native Modules for Apps In Toss",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit",
@@ -29,8 +29,8 @@
29
29
  ],
30
30
  "devDependencies": {
31
31
  "@babel/runtime": "^7",
32
- "@granite-js/native": "1.0.18",
33
- "@granite-js/react-native": "1.0.18",
32
+ "@granite-js/native": "1.0.20",
33
+ "@granite-js/react-native": "1.0.20",
34
34
  "@types/react": "19.2.3",
35
35
  "dts-bundle-generator": "^9.5.1",
36
36
  "esbuild": "0.25.5",
@@ -42,8 +42,8 @@
42
42
  "vitest": "^3.2.4"
43
43
  },
44
44
  "dependencies": {
45
- "@apps-in-toss/types": "2.4.7",
46
- "brick-module": "0.5.0",
45
+ "@apps-in-toss/types": "2.5.0",
46
+ "brick-module": "0.5.2",
47
47
  "es-toolkit": "^1.39.3"
48
48
  },
49
49
  "peerDependencies": {
@@ -13,6 +13,11 @@ import {
13
13
  } from './ads/googleAdMobV2';
14
14
  // TossPay
15
15
  import { checkoutPayment, type CheckoutPaymentOptions, type CheckoutPaymentResult } from './checkoutPayment';
16
+ import {
17
+ requestTossPayPaysBilling,
18
+ type RequestTossPayPaysBillingOptions,
19
+ type RequestTossPayPaysBillingResult,
20
+ } from './requestTossPayPaysBilling';
16
21
 
17
22
  export * from './appLogin';
18
23
  export * from './eventLog';
@@ -48,10 +53,13 @@ export * from './getGroupId';
48
53
  export * from './shareWithScheme';
49
54
  export * from './getServerTime';
50
55
  export * from './requestReview';
56
+ export * from './requestNotificationAgreement';
51
57
 
52
58
  export type {
53
59
  CheckoutPaymentOptions,
54
60
  CheckoutPaymentResult,
61
+ RequestTossPayPaysBillingOptions,
62
+ RequestTossPayPaysBillingResult,
55
63
  LoadAdMobParams,
56
64
  LoadAdMobOptions,
57
65
  LoadAdMobEvent,
@@ -67,12 +75,15 @@ export type {
67
75
  * @name TossPay
68
76
  * @description 토스페이 결제 관련 함수를 모아둔 객체예요.
69
77
  * @property {typeof checkoutPayment} [checkoutPayment] 토스페이 결제를 인증하는 함수예요. 자세한 내용은 [checkoutPayment](/react-native/reference/native-modules/토스페이/checkoutPayment)를 참고하세요.
78
+ * @property {typeof requestTossPayPaysBilling} [requestTossPayPaysBilling] 토스페이 정기결제를 인증하는 함수예요. 자세한 내용은 [requestTossPayPaysBilling](/react-native/reference/native-modules/토스페이/requestTossPayPaysBilling)를 참고하세요.
70
79
  */
71
80
  export const TossPay = {
72
81
  checkoutPayment,
82
+ requestTossPayPaysBilling,
73
83
  };
74
84
 
75
85
  export * from './checkoutPayment';
86
+ export * from './requestTossPayPaysBilling';
76
87
 
77
88
  /**
78
89
  * @public
@@ -0,0 +1,73 @@
1
+ import { noop } from 'es-toolkit';
2
+ import { isMinVersionSupported } from './isMinVersionSupported';
3
+ import { INTERNAL__appBridgeHandler } from '../native-event-emitter/internal/appBridge';
4
+
5
+ const MIN_VERSION = { android: '5.255.0', ios: '5.255.0' } as const;
6
+
7
+ function isRequestNotificationAgreementSupported() {
8
+ return isMinVersionSupported(MIN_VERSION);
9
+ }
10
+
11
+ /**
12
+ * @public
13
+ * @category 알림
14
+ * @name NotificationAgreementResult
15
+ * @description 푸시 알림 동의 플로우의 결과예요.
16
+ * @property {'newAgreement'} newAgreement - 이번에 새로 동의한 경우예요.
17
+ * @property {'alreadyAgreed'} alreadyAgreed - 이미 동의한 사용자인 경우예요.
18
+ * @property {'agreementRejected'} agreementRejected - 사용자가 동의를 거부한 경우예요.
19
+ */
20
+ export type NotificationAgreementResult = 'newAgreement' | 'alreadyAgreed' | 'agreementRejected';
21
+
22
+ /**
23
+ * @property {string} templateCode - 알림 동의를 받을 스마트발송 캠패인의 템플릿 코드예요. 코드는 앱인토스 콘솔 > 미니앱 > 스마트발송에서 작성한 값을 입력해주세요.
24
+ * @property {(result: { type: NotificationAgreementResult }) => void} onEvent - 알림 동의 결과를 콜백으로 전달해요.
25
+ * @property {(error: unknown) => void | Promise<void>} onError - 알림 동의 요청 시 에러가 발생하면 콜백으로 전달해요.
26
+ */
27
+ export interface RequestNotificationAgreementOptions {
28
+ options: { templateCode: string };
29
+ onEvent: (result: { type: NotificationAgreementResult }) => void;
30
+ onError: (error: unknown) => void | Promise<void>;
31
+ }
32
+
33
+ /**
34
+ * @public
35
+ * @category 알림
36
+ * @name requestNotificationAgreement
37
+ * @description 알림 동의 화면을 요청하고, 동의 결과를 콜백으로 전달해요.
38
+ * @param {RequestNotificationAgreementOptions} params - 템플릿 코드와 콜백이에요.
39
+ * @returns {() => void} 앱브릿지 콜백을 해제하는 함수예요.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * import { requestNotificationAgreement } from '@apps-in-toss/framework';
44
+ *
45
+ * const cleanup = requestNotificationAgreement({
46
+ * options: { templateCode: 'test-template-code' },
47
+ * onEvent: (result) => {
48
+ * console.log(result);
49
+ * cleanup();
50
+ * },
51
+ * onError: (error) => {
52
+ * console.error(error);
53
+ * cleanup();
54
+ * },
55
+ * });
56
+ * ```
57
+ */
58
+ export function requestNotificationAgreement(params: RequestNotificationAgreementOptions): () => void {
59
+ if (!isRequestNotificationAgreementSupported()) {
60
+ return noop;
61
+ }
62
+
63
+ const { options, onEvent, onError } = params;
64
+
65
+ return INTERNAL__appBridgeHandler.invokeAppBridgeMethod('requestNotificationAgreement', options, {
66
+ onSuccess: (result: { agreementResult: NotificationAgreementResult }) => {
67
+ onEvent({ type: result.agreementResult });
68
+ },
69
+ onError: (error: unknown) => {
70
+ onError(error);
71
+ },
72
+ });
73
+ }
@@ -0,0 +1,92 @@
1
+ import { isMinVersionSupported } from './isMinVersionSupported';
2
+ import { safePostMessage } from '../../natives';
3
+
4
+ const MIN_VERSION = { android: '5.256.0', ios: '5.256.0' } as const;
5
+
6
+ /**
7
+ * @public
8
+ * @category 토스페이
9
+ * @name RequestTossPayPaysBillingOptions
10
+ * @description 토스페이 정기결제창을 띄울 때 필요한 옵션이에요.
11
+ * @property {string} wrappedToken 정기결제 래핑 토큰이에요.
12
+ */
13
+ export interface RequestTossPayPaysBillingOptions {
14
+ /**
15
+ * 정기결제 래핑 토큰이에요.
16
+ */
17
+ wrappedToken: string;
18
+ }
19
+
20
+ /**
21
+ * @public
22
+ * @category 토스페이
23
+ * @name RequestTossPayPaysBillingResult
24
+ * @description 토스페이 정기결제창에서 사용자가 인증에 성공했는지 여부예요.
25
+ * @property {boolean} success 인증이 성공했는지 여부예요.
26
+ * @property {string} [reason] 인증이 실패했을 경우의 이유예요.
27
+ */
28
+ export interface RequestTossPayPaysBillingResult {
29
+ /**
30
+ * 인증이 성공했는지 여부예요.
31
+ */
32
+ success: boolean;
33
+
34
+ /**
35
+ * 인증이 실패했을 경우의 이유예요.
36
+ */
37
+ reason?: string;
38
+ }
39
+
40
+ /**
41
+ * @public
42
+ * @category 토스페이
43
+ * @name requestTossPayPaysBilling
44
+ * @description 토스페이 정기결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.
45
+ *
46
+ * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.
47
+ *
48
+ * @property {() => boolean} isSupported 현재 앱 버전이 이 기능을 지원하는지 확인하는 함수예요.
49
+ * @param {RequestTossPayPaysBillingOptions} options 정기결제창을 띄울 때 필요한 옵션이에요.
50
+ * @returns {Promise<RequestTossPayPaysBillingResult>} 인증 성공 여부를 포함한 결과를 반환해요.
51
+ *
52
+ * @example
53
+ *
54
+ * ### 토스페이 정기결제창 띄우고 인증 처리하기
55
+ *
56
+ * ```tsx
57
+ * import { TossPay } from '@apps-in-toss/framework';
58
+ *
59
+ * async function handleBilling() {
60
+ * try {
61
+ * // 실제 구현 시 정기결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.
62
+ * const { wrappedToken } = await fetch('/my-api/billing/create').then(res => res.json());
63
+ *
64
+ * const { success, reason } = await TossPay.requestTossPayPaysBilling({ wrappedToken });
65
+ *
66
+ * if (success) {
67
+ * // 실제 구현 시 정기결제를 실행하는 API 엔드포인트로 대체해주세요.
68
+ * await fetch('/my-api/billing/execute', {
69
+ * method: 'POST',
70
+ * body: JSON.stringify({ wrappedToken }),
71
+ * headers: { 'Content-Type': 'application/json' },
72
+ * });
73
+ * } else {
74
+ * console.log('인증 실패:', reason);
75
+ * }
76
+ * } catch (error) {
77
+ * console.error('정기결제 인증 중 오류가 발생했어요:', error);
78
+ * }
79
+ * }
80
+ * ```
81
+ */
82
+ export async function requestTossPayPaysBilling(options: {
83
+ params: RequestTossPayPaysBillingOptions;
84
+ }): Promise<RequestTossPayPaysBillingResult | undefined> {
85
+ if (!requestTossPayPaysBilling.isSupported()) {
86
+ console.warn('requestTossPayPaysBilling is not supported in this app version');
87
+ return;
88
+ }
89
+
90
+ return safePostMessage('requestTossPayPaysBilling', options.params);
91
+ }
92
+ requestTossPayPaysBilling.isSupported = () => isMinVersionSupported(MIN_VERSION);
@@ -14,6 +14,11 @@ import type { GameCenterGameProfileResponse } from './native-modules/getGameCent
14
14
  import type { GetUserKeyForGameResponse } from './native-modules/getUserKeyForGame';
15
15
  import type { GrantPromotionRewardForGameResponse } from './native-modules/grantPromotionRewardForGame';
16
16
  import type { IapCreateOneTimePurchaseOrderResult, IapSubscriptionInfoResult } from './native-modules/iap';
17
+ import type { RequestNotificationAgreementOptions } from './native-modules/requestNotificationAgreement';
18
+ import type {
19
+ RequestTossPayPaysBillingOptions,
20
+ RequestTossPayPaysBillingResult,
21
+ } from './native-modules/requestTossPayPaysBilling';
17
22
  import type { SaveBase64DataParams } from './native-modules/saveBase64Data';
18
23
  import type { SubmitGameCenterLeaderBoardScoreResponse } from './native-modules/submitGameCenterLeaderBoardScore';
19
24
  import { MiniAppModule } from '../spec/MiniAppModule.brick';
@@ -66,6 +71,7 @@ export interface AsyncMethodsMap {
66
71
  params: CompatiblePlaceholderArgument
67
72
  ) => Promise<{ authorizationCode: string; referrer: 'DEFAULT' | 'SANDBOX' }>;
68
73
  checkoutPayment: (params: CheckoutPaymentOptions) => Promise<CheckoutPaymentResult>;
74
+ requestTossPayPaysBilling: (params: RequestTossPayPaysBillingOptions) => Promise<RequestTossPayPaysBillingResult>;
69
75
  setDeviceOrientation: (params: { type: 'portrait' | 'landscape' }) => Promise<void>;
70
76
  saveBase64Data: (params: SaveBase64DataParams) => Promise<void>;
71
77
  appsInTossSignTossCert: (params: AppsInTossSignTossCertParams) => Promise<void>;
@@ -82,7 +88,7 @@ export interface AsyncMethodsMap {
82
88
  score: string;
83
89
  }) => Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>;
84
90
 
85
- // INTERNAL__appBridgeHandler methods (9)
91
+ // INTERNAL__appBridgeHandler methods (10)
86
92
  requestOneTimePurchase: (params: { sku: string }) => Promise<void>;
87
93
  contactsViral: (params: { moduleId: string }) => Promise<void>;
88
94
  getMiniAppsSupportContact: (params: object) => Promise<void>;
@@ -97,6 +103,7 @@ export interface AsyncMethodsMap {
97
103
  getServerTime: (params: CompatiblePlaceholderArgument) => Promise<{ serverTime: number }>;
98
104
  shareWithScheme: (params: { schemeURL: string }) => Promise<void>;
99
105
  requestMiniAppReview: (params: { title: string }) => Promise<void>;
106
+ requestNotificationAgreement: (params: RequestNotificationAgreementOptions) => Promise<void>;
100
107
  }
101
108
 
102
109
  /**
@@ -23,6 +23,7 @@ export * from './MiniAppModule/native-modules/eventLog';
23
23
  export * from './MiniAppModule/native-modules/getTossShareLink';
24
24
  export * from './MiniAppModule/native-modules/setDeviceOrientation';
25
25
  export * from './MiniAppModule/native-modules/checkoutPayment';
26
+ export * from './MiniAppModule/native-modules/requestTossPayPaysBilling';
26
27
  export * from './MiniAppModule/native-modules/saveBase64Data';
27
28
  export * from './MiniAppModule/native-modules/appsInTossSignTossCert';
28
29
  export * from './MiniAppModule/native-modules/getGameCenterGameProfile';