@apps-in-toss/native-modules 2.0.7 → 2.0.9

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.
@@ -111,9 +111,13 @@
111
111
  "identifier": "getUserKeyForGame",
112
112
  "dts": "export interface GetUserKeyForGameSuccessResponse {\n\thash: string;\n\ttype: \"HASH\";\n}\nexport interface GetUserKeyForGameErrorResponse {\n\ttype: \"NOT_AVAILABLE\";\n}\nexport type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;\n/**\n * @public\n * @category 게임\n * @name getUserKeyForGame\n * @description\n * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.\n * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.\n * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}\n * 사용자 키 조회 결과를 반환해요.\n * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.\n * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { getUserKeyForGame } from '@apps-in-toss/framework';\n *\n * function GameUserKeyButton() {\n * async function handlePress() {\n * const result = await getUserKeyForGame();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'INVALID_CATEGORY') {\n * console.error('게임 카테고리가 아닌 미니앱이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress} title=\"유저 키 가져오기\" />\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { getUserKeyForGame } from '@apps-in-toss/web-framework';\n *\n * function GameUserKeyButton() {\n * async function handleClick() {\n * const result = await getUserKeyForGame();\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'INVALID_CATEGORY') {\n * console.error('게임 카테고리가 아닌 미니앱이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('사용자 키 조회 중 오류가 발생했어요.');\n * return;\n * }\n *\n * if (result.type === 'HASH') {\n * console.log('사용자 키:', result.hash);\n * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>유저 키 가져오기</button>\n * );\n * }\n * ```\n */\nexport declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | \"INVALID_CATEGORY\" | \"ERROR\" | undefined>;\n\nexport {};\n"
113
113
  },
114
+ {
115
+ "identifier": "grantPromotionReward",
116
+ "dts": "export interface GrantPromotionRewardForGameSuccessResponse {\n\tkey: string;\n}\nexport interface GrantPromotionRewardForGameErrorResponse {\n\tcode: string;\n\t[key: string]: any;\n}\nexport interface GrantPromotionRewardForGameErrorResult {\n\terrorCode: string;\n\tmessage: string;\n}\nexport type GrantPromotionRewardSuccessResponse = GrantPromotionRewardForGameSuccessResponse;\nexport type GrantPromotionRewardErrorResponse = GrantPromotionRewardForGameErrorResponse;\nexport type GrantPromotionRewardErrorResult = GrantPromotionRewardForGameErrorResult;\nexport type GrantPromotionRewardResponse = GrantPromotionRewardSuccessResponse | GrantPromotionRewardErrorResponse;\nexport type GrantPromotionRewardResult = GrantPromotionRewardResponse | GrantPromotionRewardErrorResult | \"ERROR\" | undefined;\n/**\n * @public\n * @category 프로모션\n * @name grantPromotionReward\n * @description\n * 이 함수를 사용하면 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.\n * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.\n * @param {string} params.promotionCode - 프로모션 코드예요.\n * @param {number} params.amount - 지급할 포인트 금액이에요.\n * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}\n * 포인트 지급 결과를 반환해요.\n * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.\n * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.\n * - `\"4100\"`: 프로모션 정보를 찾을 수 없을 때\n * - `\"4104\"`: 프로모션이 중지되었을 때\n * - `\"4105\"`: 프로모션이 종료되었을 때\n * - `\"4108\"`: 프로모션이 승인되지 않았을 때\n * - `\"4109\"`: 프로모션이 실행중이 아닐 때\n * - `\"4110\"`: 리워드를 지급/회수할 수 없을 때\n * - `\"4112\"`: 프로모션 머니가 부족할 때\n * - `\"4113\"`: 이미 지급/회수된 내역일 때\n * - `\"4114\"`: 프로모션에 설정된 1회 지급 금액을 초과할 때\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n * @example\n * ```tsx\n * import { grantPromotionReward } from '@apps-in-toss/framework';\n *\n * function GrantRewardButton() {\n * async function handleClick() {\n * const result = await grantPromotionReward({\n * params: {\n * promotionCode: 'PROMOTION_CODE',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>포인트 지급하기</button>\n * );\n * }\n * ```\n */\nexport declare function grantPromotionReward(params: {\n\tparams: {\n\t\tpromotionCode: string;\n\t\tamount: number;\n\t};\n}): Promise<GrantPromotionRewardResult>;\n\nexport {};\n"
117
+ },
114
118
  {
115
119
  "identifier": "grantPromotionRewardForGame",
116
- "dts": "export interface GrantPromotionRewardForGameSuccessResponse {\n\tkey: string;\n}\nexport interface GrantPromotionRewardForGameErrorResponse {\n\tcode: string;\n\t[key: string]: any;\n}\nexport interface GrantPromotionRewardForGameErrorResult {\n\terrorCode: string;\n\tmessage: string;\n}\nexport type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;\nexport type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | \"ERROR\" | undefined;\n/**\n * @public\n * @category 게임\n * @name grantPromotionRewardForGame\n * @description\n * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.\n * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.\n * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.\n * @param {string} params.promotionCode - 프로모션 코드예요.\n * @param {number} params.amount - 지급할 포인트 금액이에요.\n * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}\n * 포인트 지급 결과를 반환해요.\n * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.\n * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.\n * - `\"40000\"`: 게임이 아닌 미니앱에서 호출했을 때\n * - `\"4100\"`: 프로모션 정보를 찾을 수 없을 때\n * - `\"4104\"`: 프로모션이 중지되었을 때\n * - `\"4105\"`: 프로모션이 종료되었을 때\n * - `\"4108\"`: 프로모션이 승인되지 않았을 때\n * - `\"4109\"`: 프로모션이 실행중이 아닐 때\n * - `\"4110\"`: 리워드를 지급/회수할 수 없을 때\n * - `\"4112\"`: 프로모션 머니가 부족할 때\n * - `\"4113\"`: 이미 지급/회수된 내역일 때\n * - `\"4114\"`: 프로모션에 설정된 1회 지급 금액을 초과할 때\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n * @example\n * ```tsx\n * // react-native\n * import { Button } from 'react-native';\n * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';\n *\n * function GrantRewardButton() {\n * async function handlePress() {\n * const result = await grantPromotionRewardForGame({\n * params: {\n * promotionCode: 'GAME_EVENT_2024',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return <Button onPress={handlePress} title=\"포인트 지급하기\" />;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // webview\n * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';\n *\n * function GrantRewardButton() {\n * async function handleClick() {\n * const result = await grantPromotionRewardForGame({\n * params: {\n * promotionCode: 'GAME_EVENT_2024',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>포인트 지급하기</button>\n * );\n * }\n * ```\n */\nexport declare function grantPromotionRewardForGame(params: {\n\tparams: {\n\t\tpromotionCode: string;\n\t\tamount: number;\n\t};\n}): Promise<GrantPromotionRewardForGameResult>;\n\nexport {};\n"
120
+ "dts": "export interface GrantPromotionRewardForGameSuccessResponse {\n\tkey: string;\n}\nexport interface GrantPromotionRewardForGameErrorResponse {\n\tcode: string;\n\t[key: string]: any;\n}\nexport interface GrantPromotionRewardForGameErrorResult {\n\terrorCode: string;\n\tmessage: string;\n}\nexport type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;\nexport type GrantPromotionRewardResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | \"ERROR\" | undefined;\n/**\n * @deprecated\n * @public\n * @category 프로모션\n * @name grantPromotionRewardForGame\n * @description\n * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.\n * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.\n * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.\n * @param {string} params.promotionCode - 프로모션 코드예요.\n * @param {number} params.amount - 지급할 포인트 금액이에요.\n * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}\n * 포인트 지급 결과를 반환해요.\n * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.\n * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.\n * - `\"40000\"`: 게임이 아닌 미니앱에서 호출했을 때\n * - `\"4100\"`: 프로모션 정보를 찾을 수 없을 때\n * - `\"4104\"`: 프로모션이 중지되었을 때\n * - `\"4105\"`: 프로모션이 종료되었을 때\n * - `\"4108\"`: 프로모션이 승인되지 않았을 때\n * - `\"4109\"`: 프로모션이 실행중이 아닐 때\n * - `\"4110\"`: 리워드를 지급/회수할 수 없을 때\n * - `\"4112\"`: 프로모션 머니가 부족할 때\n * - `\"4113\"`: 이미 지급/회수된 내역일 때\n * - `\"4114\"`: 프로모션에 설정된 1회 지급 금액을 초과할 때\n * - `'ERROR'`: 알 수 없는 오류가 발생했어요.\n * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.\n *\n * @example\n * ```tsx\n * // webview\n * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';\n *\n * function GrantRewardButton() {\n * async function handleClick() {\n * const result = await grantPromotionRewardForGame({\n * params: {\n * promotionCode: 'GAME_EVENT_2024',\n * amount: 1000,\n * },\n * });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result === 'ERROR') {\n * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');\n * return;\n * }\n *\n * if ('key' in result) {\n * console.log('포인트 지급 성공!', result.key);\n * } else if ('errorCode' in result) {\n * console.error('포인트 지급 실패:', result.errorCode, result.message);\n * }\n * }\n *\n * return (\n * <button onClick={handleClick}>포인트 지급하기</button>\n * );\n * }\n * ```\n */\nexport declare function grantPromotionRewardForGame(params: {\n\tparams: {\n\t\tpromotionCode: string;\n\t\tamount: number;\n\t};\n}): Promise<GrantPromotionRewardResult>;\n\nexport {};\n"
117
121
  },
118
122
  {
119
123
  "identifier": "getIsTossLoginIntegratedService",
package/dist/index.cjs CHANGED
@@ -52,6 +52,7 @@ __export(index_exports, {
52
52
  getTossAppVersion: () => getTossAppVersion,
53
53
  getTossShareLink: () => getTossShareLink,
54
54
  getUserKeyForGame: () => getUserKeyForGame,
55
+ grantPromotionReward: () => grantPromotionReward,
55
56
  grantPromotionRewardForGame: () => grantPromotionRewardForGame,
56
57
  iapCreateOneTimePurchaseOrder: () => iapCreateOneTimePurchaseOrder,
57
58
  isMinVersionSupported: () => isMinVersionSupported,
@@ -877,7 +878,7 @@ var GAME_USER_KEY_MIN_VERSION = {
877
878
  android: "5.232.0",
878
879
  ios: "5.232.0"
879
880
  };
880
- var GAME_PROMOTION_REWARD_MIN_VERSION = {
881
+ var PROMOTION_REWARD_MIN_VERSION = {
881
882
  android: "5.232.0",
882
883
  ios: "5.232.0"
883
884
  };
@@ -943,12 +944,12 @@ async function getUserKeyForGame() {
943
944
  }
944
945
  }
945
946
 
946
- // src/MiniAppModule/native-modules/grantPromotionRewardForGame.ts
947
- function isGrantPromotionRewardForGameError(error) {
947
+ // src/MiniAppModule/native-modules/grantPromotionReward.ts
948
+ function isGrantPromotionRewardError(error) {
948
949
  return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
949
950
  }
950
- async function grantPromotionRewardForGame(params) {
951
- const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
951
+ async function grantPromotionReward(params) {
952
+ const isSupported = isMinVersionSupported(PROMOTION_REWARD_MIN_VERSION);
952
953
  if (!isSupported) {
953
954
  return;
954
955
  }
@@ -962,7 +963,7 @@ async function grantPromotionRewardForGame(params) {
962
963
  }
963
964
  return "ERROR";
964
965
  } catch (error) {
965
- if (isGrantPromotionRewardForGameError(error)) {
966
+ if (isGrantPromotionRewardError(error)) {
966
967
  return {
967
968
  errorCode: error.code,
968
969
  message: error.message
@@ -972,6 +973,11 @@ async function grantPromotionRewardForGame(params) {
972
973
  }
973
974
  }
974
975
 
976
+ // src/MiniAppModule/native-modules/grantPromotionRewardForGame.ts
977
+ async function grantPromotionRewardForGame(params) {
978
+ return grantPromotionReward(params);
979
+ }
980
+
975
981
  // src/MiniAppModule/native-modules/getIsTossLoginIntegratedService.ts
976
982
  async function getIsTossLoginIntegratedService() {
977
983
  const isSupported = isMinVersionSupported(GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION);
@@ -1186,6 +1192,7 @@ var INTERNAL__module = {
1186
1192
  getTossAppVersion,
1187
1193
  getTossShareLink,
1188
1194
  getUserKeyForGame,
1195
+ grantPromotionReward,
1189
1196
  grantPromotionRewardForGame,
1190
1197
  iapCreateOneTimePurchaseOrder,
1191
1198
  isMinVersionSupported,
package/dist/index.d.cts CHANGED
@@ -277,10 +277,11 @@ interface GrantPromotionRewardForGameErrorResult {
277
277
  message: string;
278
278
  }
279
279
  type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;
280
- type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
280
+ type GrantPromotionRewardResult$1 = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
281
281
  /**
282
+ * @deprecated
282
283
  * @public
283
- * @category 게임
284
+ * @category 프로모션
284
285
  * @name grantPromotionRewardForGame
285
286
  * @description
286
287
  * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
@@ -304,41 +305,6 @@ type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | G
304
305
  * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
305
306
  * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
306
307
  * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
307
- * @example
308
- * ```tsx
309
- * // react-native
310
- * import { Button } from 'react-native';
311
- * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';
312
- *
313
- * function GrantRewardButton() {
314
- * async function handlePress() {
315
- * const result = await grantPromotionRewardForGame({
316
- * params: {
317
- * promotionCode: 'GAME_EVENT_2024',
318
- * amount: 1000,
319
- * },
320
- * });
321
- *
322
- * if (!result) {
323
- * console.warn('지원하지 않는 앱 버전이에요.');
324
- * return;
325
- * }
326
- *
327
- * if (result === 'ERROR') {
328
- * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
329
- * return;
330
- * }
331
- *
332
- * if ('key' in result) {
333
- * console.log('포인트 지급 성공!', result.key);
334
- * } else if ('errorCode' in result) {
335
- * console.error('포인트 지급 실패:', result.errorCode, result.message);
336
- * }
337
- * }
338
- *
339
- * return <Button onPress={handlePress} title="포인트 지급하기" />;
340
- * }
341
- * ```
342
308
  *
343
309
  * @example
344
310
  * ```tsx
@@ -382,7 +348,7 @@ declare function grantPromotionRewardForGame(params: {
382
348
  promotionCode: string;
383
349
  amount: number;
384
350
  };
385
- }): Promise<GrantPromotionRewardForGameResult>;
351
+ }): Promise<GrantPromotionRewardResult$1>;
386
352
 
387
353
  type Sku = {
388
354
  /**
@@ -2614,6 +2580,78 @@ declare const Storage: {
2614
2580
  */
2615
2581
  declare function openGameCenterLeaderboard(): Promise<void>;
2616
2582
 
2583
+ type GrantPromotionRewardSuccessResponse = GrantPromotionRewardForGameSuccessResponse;
2584
+ type GrantPromotionRewardErrorResponse = GrantPromotionRewardForGameErrorResponse;
2585
+ type GrantPromotionRewardErrorResult = GrantPromotionRewardForGameErrorResult;
2586
+ type GrantPromotionRewardResponse = GrantPromotionRewardSuccessResponse | GrantPromotionRewardErrorResponse;
2587
+ type GrantPromotionRewardResult = GrantPromotionRewardResponse | GrantPromotionRewardErrorResult | 'ERROR' | undefined;
2588
+ /**
2589
+ * @public
2590
+ * @category 프로모션
2591
+ * @name grantPromotionReward
2592
+ * @description
2593
+ * 이 함수를 사용하면 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
2594
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
2595
+ * @param {string} params.promotionCode - 프로모션 코드예요.
2596
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
2597
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
2598
+ * 포인트 지급 결과를 반환해요.
2599
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
2600
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
2601
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
2602
+ * - `"4104"`: 프로모션이 중지되었을 때
2603
+ * - `"4105"`: 프로모션이 종료되었을 때
2604
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
2605
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
2606
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
2607
+ * - `"4112"`: 프로모션 머니가 부족할 때
2608
+ * - `"4113"`: 이미 지급/회수된 내역일 때
2609
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
2610
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
2611
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
2612
+ * @example
2613
+ * ```tsx
2614
+ * import { grantPromotionReward } from '@apps-in-toss/framework';
2615
+ *
2616
+ * function GrantRewardButton() {
2617
+ * async function handleClick() {
2618
+ * const result = await grantPromotionReward({
2619
+ * params: {
2620
+ * promotionCode: 'PROMOTION_CODE',
2621
+ * amount: 1000,
2622
+ * },
2623
+ * });
2624
+ *
2625
+ * if (!result) {
2626
+ * console.warn('지원하지 않는 앱 버전이에요.');
2627
+ * return;
2628
+ * }
2629
+ *
2630
+ * if (result === 'ERROR') {
2631
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
2632
+ * return;
2633
+ * }
2634
+ *
2635
+ * if ('key' in result) {
2636
+ * console.log('포인트 지급 성공!', result.key);
2637
+ * } else if ('errorCode' in result) {
2638
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
2639
+ * }
2640
+ * }
2641
+ *
2642
+ * return (
2643
+ * <button onClick={handleClick}>포인트 지급하기</button>
2644
+ * );
2645
+ * }
2646
+ * ```
2647
+ */
2648
+ declare function grantPromotionReward(params: {
2649
+ params: {
2650
+ promotionCode: string;
2651
+ amount: number;
2652
+ };
2653
+ }): Promise<GrantPromotionRewardResult>;
2654
+
2617
2655
  /**
2618
2656
  * @public
2619
2657
  * @category 토스 로그인
@@ -3195,4 +3233,4 @@ declare const INTERNAL__module: {
3195
3233
  tossCoreEventLog: typeof tossCoreEventLog;
3196
3234
  };
3197
3235
 
3198
- export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, 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, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
3236
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, 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 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, 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, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.d.ts CHANGED
@@ -277,10 +277,11 @@ interface GrantPromotionRewardForGameErrorResult {
277
277
  message: string;
278
278
  }
279
279
  type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;
280
- type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
280
+ type GrantPromotionRewardResult$1 = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
281
281
  /**
282
+ * @deprecated
282
283
  * @public
283
- * @category 게임
284
+ * @category 프로모션
284
285
  * @name grantPromotionRewardForGame
285
286
  * @description
286
287
  * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
@@ -304,41 +305,6 @@ type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | G
304
305
  * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
305
306
  * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
306
307
  * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
307
- * @example
308
- * ```tsx
309
- * // react-native
310
- * import { Button } from 'react-native';
311
- * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';
312
- *
313
- * function GrantRewardButton() {
314
- * async function handlePress() {
315
- * const result = await grantPromotionRewardForGame({
316
- * params: {
317
- * promotionCode: 'GAME_EVENT_2024',
318
- * amount: 1000,
319
- * },
320
- * });
321
- *
322
- * if (!result) {
323
- * console.warn('지원하지 않는 앱 버전이에요.');
324
- * return;
325
- * }
326
- *
327
- * if (result === 'ERROR') {
328
- * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
329
- * return;
330
- * }
331
- *
332
- * if ('key' in result) {
333
- * console.log('포인트 지급 성공!', result.key);
334
- * } else if ('errorCode' in result) {
335
- * console.error('포인트 지급 실패:', result.errorCode, result.message);
336
- * }
337
- * }
338
- *
339
- * return <Button onPress={handlePress} title="포인트 지급하기" />;
340
- * }
341
- * ```
342
308
  *
343
309
  * @example
344
310
  * ```tsx
@@ -382,7 +348,7 @@ declare function grantPromotionRewardForGame(params: {
382
348
  promotionCode: string;
383
349
  amount: number;
384
350
  };
385
- }): Promise<GrantPromotionRewardForGameResult>;
351
+ }): Promise<GrantPromotionRewardResult$1>;
386
352
 
387
353
  type Sku = {
388
354
  /**
@@ -2614,6 +2580,78 @@ declare const Storage: {
2614
2580
  */
2615
2581
  declare function openGameCenterLeaderboard(): Promise<void>;
2616
2582
 
2583
+ type GrantPromotionRewardSuccessResponse = GrantPromotionRewardForGameSuccessResponse;
2584
+ type GrantPromotionRewardErrorResponse = GrantPromotionRewardForGameErrorResponse;
2585
+ type GrantPromotionRewardErrorResult = GrantPromotionRewardForGameErrorResult;
2586
+ type GrantPromotionRewardResponse = GrantPromotionRewardSuccessResponse | GrantPromotionRewardErrorResponse;
2587
+ type GrantPromotionRewardResult = GrantPromotionRewardResponse | GrantPromotionRewardErrorResult | 'ERROR' | undefined;
2588
+ /**
2589
+ * @public
2590
+ * @category 프로모션
2591
+ * @name grantPromotionReward
2592
+ * @description
2593
+ * 이 함수를 사용하면 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
2594
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
2595
+ * @param {string} params.promotionCode - 프로모션 코드예요.
2596
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
2597
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
2598
+ * 포인트 지급 결과를 반환해요.
2599
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
2600
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
2601
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
2602
+ * - `"4104"`: 프로모션이 중지되었을 때
2603
+ * - `"4105"`: 프로모션이 종료되었을 때
2604
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
2605
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
2606
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
2607
+ * - `"4112"`: 프로모션 머니가 부족할 때
2608
+ * - `"4113"`: 이미 지급/회수된 내역일 때
2609
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
2610
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
2611
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
2612
+ * @example
2613
+ * ```tsx
2614
+ * import { grantPromotionReward } from '@apps-in-toss/framework';
2615
+ *
2616
+ * function GrantRewardButton() {
2617
+ * async function handleClick() {
2618
+ * const result = await grantPromotionReward({
2619
+ * params: {
2620
+ * promotionCode: 'PROMOTION_CODE',
2621
+ * amount: 1000,
2622
+ * },
2623
+ * });
2624
+ *
2625
+ * if (!result) {
2626
+ * console.warn('지원하지 않는 앱 버전이에요.');
2627
+ * return;
2628
+ * }
2629
+ *
2630
+ * if (result === 'ERROR') {
2631
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
2632
+ * return;
2633
+ * }
2634
+ *
2635
+ * if ('key' in result) {
2636
+ * console.log('포인트 지급 성공!', result.key);
2637
+ * } else if ('errorCode' in result) {
2638
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
2639
+ * }
2640
+ * }
2641
+ *
2642
+ * return (
2643
+ * <button onClick={handleClick}>포인트 지급하기</button>
2644
+ * );
2645
+ * }
2646
+ * ```
2647
+ */
2648
+ declare function grantPromotionReward(params: {
2649
+ params: {
2650
+ promotionCode: string;
2651
+ amount: number;
2652
+ };
2653
+ }): Promise<GrantPromotionRewardResult>;
2654
+
2617
2655
  /**
2618
2656
  * @public
2619
2657
  * @category 토스 로그인
@@ -3195,4 +3233,4 @@ declare const INTERNAL__module: {
3195
3233
  tossCoreEventLog: typeof tossCoreEventLog;
3196
3234
  };
3197
3235
 
3198
- export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapCreateSubscriptionPurchaseOrderResult, type IapProductListItem, 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, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getGroupId, getIsTossLoginIntegratedService, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getServerTime, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
3236
+ export { type AppsInTossSignTossCertParams, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ConsumableProductListItem, type ContactsViralParams, type CreateSubscriptionPurchaseOrderOptions, type EventLogParams, type GameCenterGameProfileResponse, 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 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, 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, safePostMessage, safeSyncPostMessage, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, shareWithScheme, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.js CHANGED
@@ -799,7 +799,7 @@ var GAME_USER_KEY_MIN_VERSION = {
799
799
  android: "5.232.0",
800
800
  ios: "5.232.0"
801
801
  };
802
- var GAME_PROMOTION_REWARD_MIN_VERSION = {
802
+ var PROMOTION_REWARD_MIN_VERSION = {
803
803
  android: "5.232.0",
804
804
  ios: "5.232.0"
805
805
  };
@@ -865,12 +865,12 @@ async function getUserKeyForGame() {
865
865
  }
866
866
  }
867
867
 
868
- // src/MiniAppModule/native-modules/grantPromotionRewardForGame.ts
869
- function isGrantPromotionRewardForGameError(error) {
868
+ // src/MiniAppModule/native-modules/grantPromotionReward.ts
869
+ function isGrantPromotionRewardError(error) {
870
870
  return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
871
871
  }
872
- async function grantPromotionRewardForGame(params) {
873
- const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
872
+ async function grantPromotionReward(params) {
873
+ const isSupported = isMinVersionSupported(PROMOTION_REWARD_MIN_VERSION);
874
874
  if (!isSupported) {
875
875
  return;
876
876
  }
@@ -884,7 +884,7 @@ async function grantPromotionRewardForGame(params) {
884
884
  }
885
885
  return "ERROR";
886
886
  } catch (error) {
887
- if (isGrantPromotionRewardForGameError(error)) {
887
+ if (isGrantPromotionRewardError(error)) {
888
888
  return {
889
889
  errorCode: error.code,
890
890
  message: error.message
@@ -894,6 +894,11 @@ async function grantPromotionRewardForGame(params) {
894
894
  }
895
895
  }
896
896
 
897
+ // src/MiniAppModule/native-modules/grantPromotionRewardForGame.ts
898
+ async function grantPromotionRewardForGame(params) {
899
+ return grantPromotionReward(params);
900
+ }
901
+
897
902
  // src/MiniAppModule/native-modules/getIsTossLoginIntegratedService.ts
898
903
  async function getIsTossLoginIntegratedService() {
899
904
  const isSupported = isMinVersionSupported(GET_IS_TOSS_LOGIN_INTEGRATED_SERVICE_MIN_VERSION);
@@ -1107,6 +1112,7 @@ export {
1107
1112
  getTossAppVersion,
1108
1113
  getTossShareLink,
1109
1114
  getUserKeyForGame,
1115
+ grantPromotionReward,
1110
1116
  grantPromotionRewardForGame,
1111
1117
  iapCreateOneTimePurchaseOrder,
1112
1118
  isMinVersionSupported,
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.0.7",
4
+ "version": "2.0.9",
5
5
  "description": "Native Modules for Apps In Toss",
6
6
  "scripts": {
7
7
  "typecheck": "tsc --noEmit",
@@ -42,7 +42,7 @@
42
42
  "vitest": "^3.2.4"
43
43
  },
44
44
  "dependencies": {
45
- "@apps-in-toss/types": "2.0.7",
45
+ "@apps-in-toss/types": "2.0.9",
46
46
  "brick-module": "0.5.0",
47
47
  "es-toolkit": "^1.39.3"
48
48
  },
@@ -10,7 +10,7 @@ export const GAME_USER_KEY_MIN_VERSION = {
10
10
  ios: '5.232.0',
11
11
  } as const;
12
12
 
13
- export const GAME_PROMOTION_REWARD_MIN_VERSION = {
13
+ export const PROMOTION_REWARD_MIN_VERSION = {
14
14
  android: '5.232.0',
15
15
  ios: '5.232.0',
16
16
  } as const;
@@ -0,0 +1,118 @@
1
+ import {
2
+ GrantPromotionRewardForGameErrorResponse,
3
+ GrantPromotionRewardForGameErrorResult,
4
+ GrantPromotionRewardForGameSuccessResponse,
5
+ } from './grantPromotionRewardForGame';
6
+ import { isMinVersionSupported } from './isMinVersionSupported';
7
+ import { safePostMessage } from '../../natives';
8
+ import { PROMOTION_REWARD_MIN_VERSION } from '../constants';
9
+
10
+ export type GrantPromotionRewardSuccessResponse = GrantPromotionRewardForGameSuccessResponse;
11
+ export type GrantPromotionRewardErrorResponse = GrantPromotionRewardForGameErrorResponse;
12
+ export type GrantPromotionRewardErrorResult = GrantPromotionRewardForGameErrorResult;
13
+ export type GrantPromotionRewardResponse = GrantPromotionRewardSuccessResponse | GrantPromotionRewardErrorResponse;
14
+
15
+ type GrantPromotionRewardResult = GrantPromotionRewardResponse | GrantPromotionRewardErrorResult | 'ERROR' | undefined;
16
+
17
+ function isGrantPromotionRewardError(error: unknown): error is { code: string; message: string } {
18
+ return (
19
+ typeof error === 'object' &&
20
+ error !== null &&
21
+ 'code' in error &&
22
+ typeof (error as any).code === 'string' &&
23
+ 'message' in error &&
24
+ typeof (error as any).message === 'string'
25
+ );
26
+ }
27
+
28
+ /**
29
+ * @public
30
+ * @category 프로모션
31
+ * @name grantPromotionReward
32
+ * @description
33
+ * 이 함수를 사용하면 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
34
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
35
+ * @param {string} params.promotionCode - 프로모션 코드예요.
36
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
37
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
38
+ * 포인트 지급 결과를 반환해요.
39
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
40
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
41
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
42
+ * - `"4104"`: 프로모션이 중지되었을 때
43
+ * - `"4105"`: 프로모션이 종료되었을 때
44
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
45
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
46
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
47
+ * - `"4112"`: 프로모션 머니가 부족할 때
48
+ * - `"4113"`: 이미 지급/회수된 내역일 때
49
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
50
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
51
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
52
+ * @example
53
+ * ```tsx
54
+ * import { grantPromotionReward } from '@apps-in-toss/framework';
55
+ *
56
+ * function GrantRewardButton() {
57
+ * async function handleClick() {
58
+ * const result = await grantPromotionReward({
59
+ * params: {
60
+ * promotionCode: 'PROMOTION_CODE',
61
+ * amount: 1000,
62
+ * },
63
+ * });
64
+ *
65
+ * if (!result) {
66
+ * console.warn('지원하지 않는 앱 버전이에요.');
67
+ * return;
68
+ * }
69
+ *
70
+ * if (result === 'ERROR') {
71
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
72
+ * return;
73
+ * }
74
+ *
75
+ * if ('key' in result) {
76
+ * console.log('포인트 지급 성공!', result.key);
77
+ * } else if ('errorCode' in result) {
78
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
79
+ * }
80
+ * }
81
+ *
82
+ * return (
83
+ * <button onClick={handleClick}>포인트 지급하기</button>
84
+ * );
85
+ * }
86
+ * ```
87
+ */
88
+ export async function grantPromotionReward(params: {
89
+ params: {
90
+ promotionCode: string;
91
+ amount: number;
92
+ };
93
+ }): Promise<GrantPromotionRewardResult> {
94
+ const isSupported = isMinVersionSupported(PROMOTION_REWARD_MIN_VERSION);
95
+
96
+ if (!isSupported) {
97
+ return;
98
+ }
99
+
100
+ try {
101
+ const response = (await safePostMessage(
102
+ 'grantPromotionRewardForGame',
103
+ params.params
104
+ )) as GrantPromotionRewardResponse;
105
+ if (response.key) {
106
+ return response;
107
+ }
108
+ return 'ERROR';
109
+ } catch (error) {
110
+ if (isGrantPromotionRewardError(error)) {
111
+ return {
112
+ errorCode: error.code,
113
+ message: error.message,
114
+ };
115
+ }
116
+ return 'ERROR';
117
+ }
118
+ }
@@ -1,6 +1,4 @@
1
- import { isMinVersionSupported } from './isMinVersionSupported';
2
- import { safePostMessage } from '../../natives';
3
- import { GAME_PROMOTION_REWARD_MIN_VERSION } from '../constants';
1
+ import { grantPromotionReward } from './grantPromotionReward';
4
2
 
5
3
  export interface GrantPromotionRewardForGameSuccessResponse {
6
4
  key: string;
@@ -20,26 +18,16 @@ export type GrantPromotionRewardForGameResponse =
20
18
  | GrantPromotionRewardForGameSuccessResponse
21
19
  | GrantPromotionRewardForGameErrorResponse;
22
20
 
23
- type GrantPromotionRewardForGameResult =
21
+ type GrantPromotionRewardResult =
24
22
  | GrantPromotionRewardForGameResponse
25
23
  | GrantPromotionRewardForGameErrorResult
26
24
  | 'ERROR'
27
25
  | undefined;
28
26
 
29
- function isGrantPromotionRewardForGameError(error: unknown): error is { code: string; message: string } {
30
- return (
31
- typeof error === 'object' &&
32
- error !== null &&
33
- 'code' in error &&
34
- typeof (error as any).code === 'string' &&
35
- 'message' in error &&
36
- typeof (error as any).message === 'string'
37
- );
38
- }
39
-
40
27
  /**
28
+ * @deprecated
41
29
  * @public
42
- * @category 게임
30
+ * @category 프로모션
43
31
  * @name grantPromotionRewardForGame
44
32
  * @description
45
33
  * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
@@ -63,41 +51,6 @@ function isGrantPromotionRewardForGameError(error: unknown): error is { code: st
63
51
  * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
64
52
  * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
65
53
  * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
66
- * @example
67
- * ```tsx
68
- * // react-native
69
- * import { Button } from 'react-native';
70
- * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';
71
- *
72
- * function GrantRewardButton() {
73
- * async function handlePress() {
74
- * const result = await grantPromotionRewardForGame({
75
- * params: {
76
- * promotionCode: 'GAME_EVENT_2024',
77
- * amount: 1000,
78
- * },
79
- * });
80
- *
81
- * if (!result) {
82
- * console.warn('지원하지 않는 앱 버전이에요.');
83
- * return;
84
- * }
85
- *
86
- * if (result === 'ERROR') {
87
- * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
88
- * return;
89
- * }
90
- *
91
- * if ('key' in result) {
92
- * console.log('포인트 지급 성공!', result.key);
93
- * } else if ('errorCode' in result) {
94
- * console.error('포인트 지급 실패:', result.errorCode, result.message);
95
- * }
96
- * }
97
- *
98
- * return <Button onPress={handlePress} title="포인트 지급하기" />;
99
- * }
100
- * ```
101
54
  *
102
55
  * @example
103
56
  * ```tsx
@@ -141,29 +94,6 @@ export async function grantPromotionRewardForGame(params: {
141
94
  promotionCode: string;
142
95
  amount: number;
143
96
  };
144
- }): Promise<GrantPromotionRewardForGameResult> {
145
- const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
146
-
147
- if (!isSupported) {
148
- return;
149
- }
150
-
151
- try {
152
- const response = (await safePostMessage(
153
- 'grantPromotionRewardForGame',
154
- params.params
155
- )) as GrantPromotionRewardForGameResponse;
156
- if (response.key) {
157
- return response;
158
- }
159
- return 'ERROR';
160
- } catch (error) {
161
- if (isGrantPromotionRewardForGameError(error)) {
162
- return {
163
- errorCode: error.code,
164
- message: error.message,
165
- };
166
- }
167
- return 'ERROR';
168
- }
97
+ }): Promise<GrantPromotionRewardResult> {
98
+ return grantPromotionReward(params);
169
99
  }
@@ -38,6 +38,7 @@ export * from './openGameCenterLeaderboard';
38
38
  export * from './getGameCenterGameProfile';
39
39
  export * from './submitGameCenterLeaderBoardScore';
40
40
  export * from './getUserKeyForGame';
41
+ export * from './grantPromotionReward';
41
42
  export * from './grantPromotionRewardForGame';
42
43
  export * from './getIsTossLoginIntegratedService';
43
44
  export * from '../native-event-emitter/contactsViral';
@@ -29,6 +29,7 @@ export * from './MiniAppModule/native-modules/getGameCenterGameProfile';
29
29
  export * from './MiniAppModule/native-modules/openGameCenterLeaderboard';
30
30
  export * from './MiniAppModule/native-modules/submitGameCenterLeaderBoardScore';
31
31
  export * from './MiniAppModule/native-modules/getUserKeyForGame';
32
+ export * from './MiniAppModule/native-modules/grantPromotionReward';
32
33
  export * from './MiniAppModule/native-modules/grantPromotionRewardForGame';
33
34
  export * from './MiniAppModule/native-modules/getIsTossLoginIntegratedService';
34
35
  export * from './MiniAppModule/native-modules/getServerTime';