@apps-in-toss/native-modules 1.3.0 → 1.4.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.
@@ -107,6 +107,14 @@
107
107
  "identifier": "submitGameCenterLeaderBoardScore",
108
108
  "dts": "/**\n * @public\n * @category 게임센터\n * @name SubmitGameCenterLeaderBoardScoreResponse\n * @description\n * 토스게임센터 리더보드에 점수를 제출한 결과 정보를 담아서 반환해요. 반환된 정보를 사용해서 점수 제출 결과에 따라 적절한 에러 처리를 할 수 있어요.\n * @property {'SUCCESS' | 'LEADERBOARD_NOT_FOUND' | 'PROFILE_NOT_FOUND' | 'UNPARSABLE_SCORE'} statusCode\n * 점수 제출 결과를 나타내는 상태 코드예요.\n * - `'SUCCESS'`: 점수 제출이 성공했어요.\n * - `'LEADERBOARD_NOT_FOUND'`: `gameId`에 해당하는 리더보드를 찾을 수 없어요.\n * - `'PROFILE_NOT_FOUND'`: 사용자의 프로필이 없어요.\n * - `'UNPARSABLE_SCORE'`: 점수를 해석할 수 없어요. 점수는 실수(float) 형태의 문자열로 전달해야 해요.\n */\nexport interface SubmitGameCenterLeaderBoardScoreResponse {\n\tstatusCode: \"SUCCESS\" | \"LEADERBOARD_NOT_FOUND\" | \"PROFILE_NOT_FOUND\" | \"UNPARSABLE_SCORE\";\n}\n/**\n * @public\n * @category 게임센터\n * @name submitGameCenterLeaderBoardScore\n * @description\n * 사용자의 게임 점수를 토스게임센터 리더보드에 제출해요. 이 기능으로 사용자의 점수를 공식 리더보드에 기록하고 다른 사용자와 비교할 수 있어요.\n * @param {string} params.score\n * 제출할 게임 점수예요. 실수 형태의 숫자를 문자열로 전달해야 해요. 예를들어 `\"123.45\"` 또는 `\"9999\"` 예요.\n * @returns {Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>}\n * 점수 제출 결과를 반환해요. 앱 버전이 최소 지원 버전보다 낮으면 아무 동작도 하지 않고 `undefined`를 반환해요.\n *\n * @example\n * ### 게임 점수를 토스게임센터 리더보드에 제출하기\n * ```tsx\n * import { Button } from 'react-native';\n * import { submitGameCenterLeaderBoardScore } from '@apps-in-toss/framework';\n *\n * function GameCenterLeaderBoardScoreSubmitButton() {\n * async function handlePress() {\n * try {\n * const result = await submitGameCenterLeaderBoardScore({ score: '123.45' });\n *\n * if (!result) {\n * console.warn('지원하지 않는 앱 버전이에요.');\n * return;\n * }\n *\n * if (result.statusCode === 'SUCCESS') {\n * console.log('점수 제출 성공!');\n * } else {\n * console.error('점수 제출 실패:', result.statusCode);\n * }\n * } catch (error) {\n * console.error('점수 제출 중 오류가 발생했어요.', error);\n * }\n * }\n *\n * return (\n * <Button onPress={handlePress}>점수 제출하기</Button>\n * );\n * }\n * ```\n */\nexport declare function submitGameCenterLeaderBoardScore(params: {\n\tscore: string;\n}): Promise<SubmitGameCenterLeaderBoardScoreResponse | undefined>;\n\nexport {};\n"
109
109
  },
110
+ {
111
+ "identifier": "getUserKeyForGame",
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
+ },
114
+ {
115
+ "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"
117
+ },
110
118
  {
111
119
  "identifier": "getLocale",
112
120
  "dts": "/**\n * @public\n * @category 언어\n * @kind function\n * @name getLocale\n * @description\n * 사용자의 로케일(locale) 정보를 반환해요. 네이티브 모듈에서 로케일 정보를 가져올 수 없을 때는 기본값으로 'ko-KR'을 반환합니다. 앱의 현지화 및 언어 설정과 관련된 기능을 구현할 때 사용하세요.\n *\n * @returns {string} 사용자의 로케일 정보를 반환해요.\n *\n * @example\n * ### 현재 사용자의 로케일 정보 가져오기\n *\n * ```tsx\n * import { getLocale } from '@apps-in-toss/native-modules';\n * import { Text } from 'react-native';\n *\n * function MyPage() {\n * const locale = getLocale();\n *\n * return (\n * <Text>사용자의 로케일 정보: {locale}</Text>\n * )\n * }\n *\n * ```\n */\nexport declare function getLocale(): string;\n\nexport {};\n"
package/dist/index.cjs CHANGED
@@ -51,6 +51,8 @@ __export(index_exports, {
51
51
  getSchemeUri: () => getSchemeUri2,
52
52
  getTossAppVersion: () => getTossAppVersion,
53
53
  getTossShareLink: () => getTossShareLink,
54
+ getUserKeyForGame: () => getUserKeyForGame,
55
+ grantPromotionRewardForGame: () => grantPromotionRewardForGame,
54
56
  iapCreateOneTimePurchaseOrder: () => iapCreateOneTimePurchaseOrder,
55
57
  isMinVersionSupported: () => isMinVersionSupported,
56
58
  onVisibilityChangedByTransparentServiceWeb: () => onVisibilityChangedByTransparentServiceWeb,
@@ -914,6 +916,14 @@ var GAME_CENTER_MIN_VERSION = {
914
916
  android: "5.221.0",
915
917
  ios: "5.221.0"
916
918
  };
919
+ var GAME_USER_KEY_MIN_VERSION = {
920
+ android: "5.232.0",
921
+ ios: "5.232.0"
922
+ };
923
+ var GAME_PROMOTION_REWARD_MIN_VERSION = {
924
+ android: "5.232.0",
925
+ ios: "5.232.0"
926
+ };
917
927
 
918
928
  // src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
919
929
  async function openGameCenterLeaderboard() {
@@ -948,6 +958,54 @@ async function submitGameCenterLeaderBoardScore(params) {
948
958
  return AppsInTossModule.submitGameCenterLeaderBoardScore(params);
949
959
  }
950
960
 
961
+ // src/AppsInTossModule/native-modules/getUserKeyForGame.ts
962
+ async function getUserKeyForGame() {
963
+ const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
964
+ if (!isSupported) {
965
+ return;
966
+ }
967
+ try {
968
+ const response = await AppsInTossModule.getUserKeyForGame({});
969
+ if (response.type === "HASH") {
970
+ return response;
971
+ }
972
+ if (response.type === "NOT_AVAILABLE") {
973
+ return "INVALID_CATEGORY";
974
+ }
975
+ return "ERROR";
976
+ } catch (_) {
977
+ return "ERROR";
978
+ }
979
+ }
980
+
981
+ // src/AppsInTossModule/native-modules/grantPromotionRewardForGame.ts
982
+ function isGrantPromotionRewardForGameError(error) {
983
+ return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
984
+ }
985
+ async function grantPromotionRewardForGame({
986
+ params
987
+ }) {
988
+ const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
989
+ if (!isSupported) {
990
+ return;
991
+ }
992
+ try {
993
+ const response = await AppsInTossModule.grantPromotionRewardForGame({ params });
994
+ if (response.key) {
995
+ return response;
996
+ }
997
+ return "ERROR";
998
+ } catch (error) {
999
+ if (isGrantPromotionRewardForGameError(error)) {
1000
+ return {
1001
+ errorCode: error.code,
1002
+ message: error.message
1003
+ };
1004
+ }
1005
+ return "ERROR";
1006
+ }
1007
+ }
1008
+
951
1009
  // src/AppsInTossModule/native-event-emitter/contactsViral.ts
952
1010
  function contactsViral(params) {
953
1011
  const isSupported = isMinVersionSupported({
@@ -1143,6 +1201,8 @@ var INTERNAL__module = {
1143
1201
  getSchemeUri,
1144
1202
  getTossAppVersion,
1145
1203
  getTossShareLink,
1204
+ getUserKeyForGame,
1205
+ grantPromotionRewardForGame,
1146
1206
  iapCreateOneTimePurchaseOrder,
1147
1207
  isMinVersionSupported,
1148
1208
  onVisibilityChangedByTransparentServiceWeb,
package/dist/index.d.cts CHANGED
@@ -1443,6 +1443,222 @@ type GameCenterGameProfileResponse = {
1443
1443
  */
1444
1444
  declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
1445
1445
 
1446
+ interface GetUserKeyForGameSuccessResponse {
1447
+ hash: string;
1448
+ type: 'HASH';
1449
+ }
1450
+ interface GetUserKeyForGameErrorResponse {
1451
+ type: 'NOT_AVAILABLE';
1452
+ }
1453
+ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
1454
+ /**
1455
+ * @public
1456
+ * @category 게임
1457
+ * @name getUserKeyForGame
1458
+ * @description
1459
+ * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
1460
+ * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
1461
+ * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
1462
+ * 사용자 키 조회 결과를 반환해요.
1463
+ * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
1464
+ * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
1465
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
1466
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
1467
+ *
1468
+ * @example
1469
+ * ```tsx
1470
+ * // react-native
1471
+ * import { Button } from 'react-native';
1472
+ * import { getUserKeyForGame } from '@apps-in-toss/framework';
1473
+ *
1474
+ * function GameUserKeyButton() {
1475
+ * async function handlePress() {
1476
+ * const result = await getUserKeyForGame();
1477
+ *
1478
+ * if (!result) {
1479
+ * console.warn('지원하지 않는 앱 버전이에요.');
1480
+ * return;
1481
+ * }
1482
+ *
1483
+ * if (result === 'INVALID_CATEGORY') {
1484
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
1485
+ * return;
1486
+ * }
1487
+ *
1488
+ * if (result === 'ERROR') {
1489
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
1490
+ * return;
1491
+ * }
1492
+ *
1493
+ * if (result.type === 'HASH') {
1494
+ * console.log('사용자 키:', result.hash);
1495
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
1496
+ * }
1497
+ * }
1498
+ *
1499
+ * return (
1500
+ * <Button onPress={handlePress} title="유저 키 가져오기" />
1501
+ * );
1502
+ * }
1503
+ * ```
1504
+ *
1505
+ * @example
1506
+ * ```tsx
1507
+ * // webview
1508
+ * import { getUserKeyForGame } from '@apps-in-toss/web-framework';
1509
+ *
1510
+ * function GameUserKeyButton() {
1511
+ * async function handleClick() {
1512
+ * const result = await getUserKeyForGame();
1513
+ *
1514
+ * if (!result) {
1515
+ * console.warn('지원하지 않는 앱 버전이에요.');
1516
+ * return;
1517
+ * }
1518
+ *
1519
+ * if (result === 'INVALID_CATEGORY') {
1520
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
1521
+ * return;
1522
+ * }
1523
+ *
1524
+ * if (result === 'ERROR') {
1525
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
1526
+ * return;
1527
+ * }
1528
+ *
1529
+ * if (result.type === 'HASH') {
1530
+ * console.log('사용자 키:', result.hash);
1531
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
1532
+ * }
1533
+ * }
1534
+ *
1535
+ * return (
1536
+ * <button onClick={handleClick}>유저 키 가져오기</button>
1537
+ * );
1538
+ * }
1539
+ * ```
1540
+ */
1541
+ declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
1542
+
1543
+ interface GrantPromotionRewardForGameSuccessResponse {
1544
+ key: string;
1545
+ }
1546
+ interface GrantPromotionRewardForGameErrorResponse {
1547
+ code: string;
1548
+ [key: string]: any;
1549
+ }
1550
+ interface GrantPromotionRewardForGameErrorResult {
1551
+ errorCode: string;
1552
+ message: string;
1553
+ }
1554
+ type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;
1555
+ type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
1556
+ /**
1557
+ * @public
1558
+ * @category 게임
1559
+ * @name grantPromotionRewardForGame
1560
+ * @description
1561
+ * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
1562
+ * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.
1563
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
1564
+ * @param {string} params.promotionCode - 프로모션 코드예요.
1565
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
1566
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
1567
+ * 포인트 지급 결과를 반환해요.
1568
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
1569
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
1570
+ * - `"40000"`: 게임이 아닌 미니앱에서 호출했을 때
1571
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
1572
+ * - `"4104"`: 프로모션이 중지되었을 때
1573
+ * - `"4105"`: 프로모션이 종료되었을 때
1574
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
1575
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
1576
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
1577
+ * - `"4112"`: 프로모션 머니가 부족할 때
1578
+ * - `"4113"`: 이미 지급/회수된 내역일 때
1579
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
1580
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
1581
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
1582
+ * @example
1583
+ * ```tsx
1584
+ * // react-native
1585
+ * import { Button } from 'react-native';
1586
+ * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';
1587
+ *
1588
+ * function GrantRewardButton() {
1589
+ * async function handlePress() {
1590
+ * const result = await grantPromotionRewardForGame({
1591
+ * params: {
1592
+ * promotionCode: 'GAME_EVENT_2024',
1593
+ * amount: 1000,
1594
+ * },
1595
+ * });
1596
+ *
1597
+ * if (!result) {
1598
+ * console.warn('지원하지 않는 앱 버전이에요.');
1599
+ * return;
1600
+ * }
1601
+ *
1602
+ * if (result === 'ERROR') {
1603
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
1604
+ * return;
1605
+ * }
1606
+ *
1607
+ * if ('key' in result) {
1608
+ * console.log('포인트 지급 성공!', result.key);
1609
+ * } else if ('errorCode' in result) {
1610
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
1611
+ * }
1612
+ * }
1613
+ *
1614
+ * return <Button onPress={handlePress} title="포인트 지급하기" />;
1615
+ * }
1616
+ * ```
1617
+ *
1618
+ * @example
1619
+ * ```tsx
1620
+ * // webview
1621
+ * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';
1622
+ *
1623
+ * function GrantRewardButton() {
1624
+ * async function handleClick() {
1625
+ * const result = await grantPromotionRewardForGame({
1626
+ * params: {
1627
+ * promotionCode: 'GAME_EVENT_2024',
1628
+ * amount: 1000,
1629
+ * },
1630
+ * });
1631
+ *
1632
+ * if (!result) {
1633
+ * console.warn('지원하지 않는 앱 버전이에요.');
1634
+ * return;
1635
+ * }
1636
+ *
1637
+ * if (result === 'ERROR') {
1638
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
1639
+ * return;
1640
+ * }
1641
+ *
1642
+ * if ('key' in result) {
1643
+ * console.log('포인트 지급 성공!', result.key);
1644
+ * } else if ('errorCode' in result) {
1645
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
1646
+ * }
1647
+ * }
1648
+ *
1649
+ * return (
1650
+ * <button onClick={handleClick}>포인트 지급하기</button>
1651
+ * );
1652
+ * }
1653
+ * ```
1654
+ */
1655
+ declare function grantPromotionRewardForGame({ params, }: {
1656
+ params: {
1657
+ promotionCode: string;
1658
+ amount: number;
1659
+ };
1660
+ }): Promise<GrantPromotionRewardForGameResult>;
1661
+
1446
1662
  type Sku = {
1447
1663
  /**
1448
1664
  * @deprecated `productId`는 더 이상 사용하지 않아요. 대신 `sku`를 사용해요.
@@ -1980,6 +2196,13 @@ interface Spec extends TurboModule {
1980
2196
  };
1981
2197
  }) => Promise<boolean>;
1982
2198
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse>;
2199
+ getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse>;
2200
+ grantPromotionRewardForGame: (params: {
2201
+ params: {
2202
+ promotionCode: string;
2203
+ amount: number;
2204
+ };
2205
+ }) => Promise<GrantPromotionRewardForGameResponse>;
1983
2206
  submitGameCenterLeaderBoardScore: (params: {
1984
2207
  score: string;
1985
2208
  }) => Promise<SubmitGameCenterLeaderBoardScoreResponse>;
@@ -3401,4 +3624,4 @@ declare const INTERNAL__module: {
3401
3624
  tossCoreEventLog: typeof tossCoreEventLog;
3402
3625
  };
3403
3626
 
3404
- export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, GoogleAdMob, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type LoadAdMobEvent, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobOptions, type LoadAdMobParams, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobOptions, type ShowAdMobParams, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
3627
+ export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type LoadAdMobEvent, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobOptions, type LoadAdMobParams, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobOptions, type ShowAdMobParams, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.d.ts CHANGED
@@ -1443,6 +1443,222 @@ type GameCenterGameProfileResponse = {
1443
1443
  */
1444
1444
  declare function getGameCenterGameProfile(): Promise<GameCenterGameProfileResponse | undefined>;
1445
1445
 
1446
+ interface GetUserKeyForGameSuccessResponse {
1447
+ hash: string;
1448
+ type: 'HASH';
1449
+ }
1450
+ interface GetUserKeyForGameErrorResponse {
1451
+ type: 'NOT_AVAILABLE';
1452
+ }
1453
+ type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
1454
+ /**
1455
+ * @public
1456
+ * @category 게임
1457
+ * @name getUserKeyForGame
1458
+ * @description
1459
+ * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
1460
+ * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
1461
+ * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
1462
+ * 사용자 키 조회 결과를 반환해요.
1463
+ * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
1464
+ * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
1465
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
1466
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
1467
+ *
1468
+ * @example
1469
+ * ```tsx
1470
+ * // react-native
1471
+ * import { Button } from 'react-native';
1472
+ * import { getUserKeyForGame } from '@apps-in-toss/framework';
1473
+ *
1474
+ * function GameUserKeyButton() {
1475
+ * async function handlePress() {
1476
+ * const result = await getUserKeyForGame();
1477
+ *
1478
+ * if (!result) {
1479
+ * console.warn('지원하지 않는 앱 버전이에요.');
1480
+ * return;
1481
+ * }
1482
+ *
1483
+ * if (result === 'INVALID_CATEGORY') {
1484
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
1485
+ * return;
1486
+ * }
1487
+ *
1488
+ * if (result === 'ERROR') {
1489
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
1490
+ * return;
1491
+ * }
1492
+ *
1493
+ * if (result.type === 'HASH') {
1494
+ * console.log('사용자 키:', result.hash);
1495
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
1496
+ * }
1497
+ * }
1498
+ *
1499
+ * return (
1500
+ * <Button onPress={handlePress} title="유저 키 가져오기" />
1501
+ * );
1502
+ * }
1503
+ * ```
1504
+ *
1505
+ * @example
1506
+ * ```tsx
1507
+ * // webview
1508
+ * import { getUserKeyForGame } from '@apps-in-toss/web-framework';
1509
+ *
1510
+ * function GameUserKeyButton() {
1511
+ * async function handleClick() {
1512
+ * const result = await getUserKeyForGame();
1513
+ *
1514
+ * if (!result) {
1515
+ * console.warn('지원하지 않는 앱 버전이에요.');
1516
+ * return;
1517
+ * }
1518
+ *
1519
+ * if (result === 'INVALID_CATEGORY') {
1520
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
1521
+ * return;
1522
+ * }
1523
+ *
1524
+ * if (result === 'ERROR') {
1525
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
1526
+ * return;
1527
+ * }
1528
+ *
1529
+ * if (result.type === 'HASH') {
1530
+ * console.log('사용자 키:', result.hash);
1531
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
1532
+ * }
1533
+ * }
1534
+ *
1535
+ * return (
1536
+ * <button onClick={handleClick}>유저 키 가져오기</button>
1537
+ * );
1538
+ * }
1539
+ * ```
1540
+ */
1541
+ declare function getUserKeyForGame(): Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>;
1542
+
1543
+ interface GrantPromotionRewardForGameSuccessResponse {
1544
+ key: string;
1545
+ }
1546
+ interface GrantPromotionRewardForGameErrorResponse {
1547
+ code: string;
1548
+ [key: string]: any;
1549
+ }
1550
+ interface GrantPromotionRewardForGameErrorResult {
1551
+ errorCode: string;
1552
+ message: string;
1553
+ }
1554
+ type GrantPromotionRewardForGameResponse = GrantPromotionRewardForGameSuccessResponse | GrantPromotionRewardForGameErrorResponse;
1555
+ type GrantPromotionRewardForGameResult = GrantPromotionRewardForGameResponse | GrantPromotionRewardForGameErrorResult | 'ERROR' | undefined;
1556
+ /**
1557
+ * @public
1558
+ * @category 게임
1559
+ * @name grantPromotionRewardForGame
1560
+ * @description
1561
+ * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
1562
+ * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.
1563
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
1564
+ * @param {string} params.promotionCode - 프로모션 코드예요.
1565
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
1566
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
1567
+ * 포인트 지급 결과를 반환해요.
1568
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
1569
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
1570
+ * - `"40000"`: 게임이 아닌 미니앱에서 호출했을 때
1571
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
1572
+ * - `"4104"`: 프로모션이 중지되었을 때
1573
+ * - `"4105"`: 프로모션이 종료되었을 때
1574
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
1575
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
1576
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
1577
+ * - `"4112"`: 프로모션 머니가 부족할 때
1578
+ * - `"4113"`: 이미 지급/회수된 내역일 때
1579
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
1580
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
1581
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
1582
+ * @example
1583
+ * ```tsx
1584
+ * // react-native
1585
+ * import { Button } from 'react-native';
1586
+ * import { grantPromotionRewardForGame } from '@apps-in-toss/framework';
1587
+ *
1588
+ * function GrantRewardButton() {
1589
+ * async function handlePress() {
1590
+ * const result = await grantPromotionRewardForGame({
1591
+ * params: {
1592
+ * promotionCode: 'GAME_EVENT_2024',
1593
+ * amount: 1000,
1594
+ * },
1595
+ * });
1596
+ *
1597
+ * if (!result) {
1598
+ * console.warn('지원하지 않는 앱 버전이에요.');
1599
+ * return;
1600
+ * }
1601
+ *
1602
+ * if (result === 'ERROR') {
1603
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
1604
+ * return;
1605
+ * }
1606
+ *
1607
+ * if ('key' in result) {
1608
+ * console.log('포인트 지급 성공!', result.key);
1609
+ * } else if ('errorCode' in result) {
1610
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
1611
+ * }
1612
+ * }
1613
+ *
1614
+ * return <Button onPress={handlePress} title="포인트 지급하기" />;
1615
+ * }
1616
+ * ```
1617
+ *
1618
+ * @example
1619
+ * ```tsx
1620
+ * // webview
1621
+ * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';
1622
+ *
1623
+ * function GrantRewardButton() {
1624
+ * async function handleClick() {
1625
+ * const result = await grantPromotionRewardForGame({
1626
+ * params: {
1627
+ * promotionCode: 'GAME_EVENT_2024',
1628
+ * amount: 1000,
1629
+ * },
1630
+ * });
1631
+ *
1632
+ * if (!result) {
1633
+ * console.warn('지원하지 않는 앱 버전이에요.');
1634
+ * return;
1635
+ * }
1636
+ *
1637
+ * if (result === 'ERROR') {
1638
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
1639
+ * return;
1640
+ * }
1641
+ *
1642
+ * if ('key' in result) {
1643
+ * console.log('포인트 지급 성공!', result.key);
1644
+ * } else if ('errorCode' in result) {
1645
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
1646
+ * }
1647
+ * }
1648
+ *
1649
+ * return (
1650
+ * <button onClick={handleClick}>포인트 지급하기</button>
1651
+ * );
1652
+ * }
1653
+ * ```
1654
+ */
1655
+ declare function grantPromotionRewardForGame({ params, }: {
1656
+ params: {
1657
+ promotionCode: string;
1658
+ amount: number;
1659
+ };
1660
+ }): Promise<GrantPromotionRewardForGameResult>;
1661
+
1446
1662
  type Sku = {
1447
1663
  /**
1448
1664
  * @deprecated `productId`는 더 이상 사용하지 않아요. 대신 `sku`를 사용해요.
@@ -1980,6 +2196,13 @@ interface Spec extends TurboModule {
1980
2196
  };
1981
2197
  }) => Promise<boolean>;
1982
2198
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse>;
2199
+ getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse>;
2200
+ grantPromotionRewardForGame: (params: {
2201
+ params: {
2202
+ promotionCode: string;
2203
+ amount: number;
2204
+ };
2205
+ }) => Promise<GrantPromotionRewardForGameResponse>;
1983
2206
  submitGameCenterLeaderBoardScore: (params: {
1984
2207
  score: string;
1985
2208
  }) => Promise<SubmitGameCenterLeaderBoardScoreResponse>;
@@ -3401,4 +3624,4 @@ declare const INTERNAL__module: {
3401
3624
  tossCoreEventLog: typeof tossCoreEventLog;
3402
3625
  };
3403
3626
 
3404
- export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, GoogleAdMob, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type LoadAdMobEvent, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobOptions, type LoadAdMobParams, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobOptions, type ShowAdMobParams, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
3627
+ export { AppsInTossModule, type AppsInTossSignTossCertParams, BedrockCoreModule, BedrockModule, type CheckoutPaymentOptions, type CheckoutPaymentResult, type CompletedOrRefundedOrdersResult, type ContactsViralParams, type EventLogParams, type GameCenterGameProfileResponse, type GetUserKeyForGameErrorResponse, type GetUserKeyForGameResponse, type GetUserKeyForGameSuccessResponse, GoogleAdMob, type GrantPromotionRewardForGameErrorResponse, type GrantPromotionRewardForGameErrorResult, type GrantPromotionRewardForGameResponse, type GrantPromotionRewardForGameSuccessResponse, type HapticFeedbackType, IAP, AppsInTossModuleInstance as INTERNAL__AppsInTossModule, INTERNAL__appBridgeHandler, INTERNAL__module, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type LoadAdMobEvent, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobOptions, type LoadAdMobParams, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type NetworkStatus, type Primitive, type SaveBase64DataParams, type ShowAdMobEvent, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobOptions, type ShowAdMobParams, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, Storage, type SubmitGameCenterLeaderBoardScoreResponse, TossPay, type UpdateLocationEventEmitter, appLogin, appsInTossEvent, appsInTossSignTossCert, closeView, contactsViral, eventLog, fetchAlbumPhotos, fetchContacts, generateHapticFeedback, getClipboardText, getCurrentLocation, getDeviceId, getGameCenterGameProfile, getLocale, getNetworkStatus, getOperationalEnvironment, getPlatformOS, getSchemeUri, getTossAppVersion, getTossShareLink, getUserKeyForGame, grantPromotionRewardForGame, iapCreateOneTimePurchaseOrder, isMinVersionSupported, onVisibilityChangedByTransparentServiceWeb, openCamera, openGameCenterLeaderboard, openURL, processProductGrant, requestOneTimePurchase, saveBase64Data, setClipboardText, setDeviceOrientation, setIosSwipeGestureEnabled, setScreenAwakeMode, setSecureScreen, share, startUpdateLocation, submitGameCenterLeaderBoardScore };
package/dist/index.js CHANGED
@@ -841,6 +841,14 @@ var GAME_CENTER_MIN_VERSION = {
841
841
  android: "5.221.0",
842
842
  ios: "5.221.0"
843
843
  };
844
+ var GAME_USER_KEY_MIN_VERSION = {
845
+ android: "5.232.0",
846
+ ios: "5.232.0"
847
+ };
848
+ var GAME_PROMOTION_REWARD_MIN_VERSION = {
849
+ android: "5.232.0",
850
+ ios: "5.232.0"
851
+ };
844
852
 
845
853
  // src/AppsInTossModule/native-modules/openGameCenterLeaderboard.ts
846
854
  async function openGameCenterLeaderboard() {
@@ -875,6 +883,54 @@ async function submitGameCenterLeaderBoardScore(params) {
875
883
  return AppsInTossModule.submitGameCenterLeaderBoardScore(params);
876
884
  }
877
885
 
886
+ // src/AppsInTossModule/native-modules/getUserKeyForGame.ts
887
+ async function getUserKeyForGame() {
888
+ const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
889
+ if (!isSupported) {
890
+ return;
891
+ }
892
+ try {
893
+ const response = await AppsInTossModule.getUserKeyForGame({});
894
+ if (response.type === "HASH") {
895
+ return response;
896
+ }
897
+ if (response.type === "NOT_AVAILABLE") {
898
+ return "INVALID_CATEGORY";
899
+ }
900
+ return "ERROR";
901
+ } catch (_) {
902
+ return "ERROR";
903
+ }
904
+ }
905
+
906
+ // src/AppsInTossModule/native-modules/grantPromotionRewardForGame.ts
907
+ function isGrantPromotionRewardForGameError(error) {
908
+ return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string" && "message" in error && typeof error.message === "string";
909
+ }
910
+ async function grantPromotionRewardForGame({
911
+ params
912
+ }) {
913
+ const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
914
+ if (!isSupported) {
915
+ return;
916
+ }
917
+ try {
918
+ const response = await AppsInTossModule.grantPromotionRewardForGame({ params });
919
+ if (response.key) {
920
+ return response;
921
+ }
922
+ return "ERROR";
923
+ } catch (error) {
924
+ if (isGrantPromotionRewardForGameError(error)) {
925
+ return {
926
+ errorCode: error.code,
927
+ message: error.message
928
+ };
929
+ }
930
+ return "ERROR";
931
+ }
932
+ }
933
+
878
934
  // src/AppsInTossModule/native-event-emitter/contactsViral.ts
879
935
  function contactsViral(params) {
880
936
  const isSupported = isMinVersionSupported({
@@ -1069,6 +1125,8 @@ export {
1069
1125
  getSchemeUri2 as getSchemeUri,
1070
1126
  getTossAppVersion,
1071
1127
  getTossShareLink,
1128
+ getUserKeyForGame,
1129
+ grantPromotionRewardForGame,
1072
1130
  iapCreateOneTimePurchaseOrder,
1073
1131
  isMinVersionSupported,
1074
1132
  onVisibilityChangedByTransparentServiceWeb,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/native-modules",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "description": "Native Modules for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -43,7 +43,7 @@
43
43
  "vitest": "^3.2.4"
44
44
  },
45
45
  "dependencies": {
46
- "@apps-in-toss/types": "^1.3.0",
46
+ "@apps-in-toss/types": "^1.4.0",
47
47
  "es-toolkit": "^1.39.3"
48
48
  },
49
49
  "peerDependencies": {
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "71845fd4a349b630c91f07c3ab3d14f81774335a"
57
+ "gitHead": "b75a03ae2d9de16548e7ec020cbe036fe9896016"
58
58
  }
@@ -4,3 +4,13 @@ export const GAME_CENTER_MIN_VERSION = {
4
4
  android: '5.221.0',
5
5
  ios: '5.221.0',
6
6
  } as const;
7
+
8
+ export const GAME_USER_KEY_MIN_VERSION = {
9
+ android: '5.232.0',
10
+ ios: '5.232.0',
11
+ } as const;
12
+
13
+ export const GAME_PROMOTION_REWARD_MIN_VERSION = {
14
+ android: '5.232.0',
15
+ ios: '5.232.0',
16
+ } as const;
@@ -16,6 +16,8 @@ import { TurboModuleRegistry, type TurboModule as __TurboModule } from 'react-na
16
16
  import type { AppsInTossSignTossCertParams } from './appsInTossSignTossCert';
17
17
  import type { CheckoutPaymentOptions, CheckoutPaymentResult } from './checkoutPayment';
18
18
  import type { GameCenterGameProfileResponse } from './getGameCenterGameProfile';
19
+ import { GetUserKeyForGameResponse } from './getUserKeyForGame';
20
+ import { GrantPromotionRewardForGameResponse } from './grantPromotionRewardForGame';
19
21
  import { IapCreateOneTimePurchaseOrderResult, IapProductListItem, CompletedOrRefundedOrdersResult } from './iap';
20
22
  import type { SaveBase64DataParams } from './saveBase64Data';
21
23
  import type { SubmitGameCenterLeaderBoardScoreResponse } from './submitGameCenterLeaderBoardScore';
@@ -78,6 +80,10 @@ interface Spec extends __TurboModule {
78
80
  completeProductGrant: (params: { params: { orderId: string } }) => Promise<boolean>;
79
81
 
80
82
  getGameCenterGameProfile: (params: CompatiblePlaceholderArgument) => Promise<GameCenterGameProfileResponse>;
83
+ getUserKeyForGame: (params: CompatiblePlaceholderArgument) => Promise<GetUserKeyForGameResponse>;
84
+ grantPromotionRewardForGame: (params: {
85
+ params: { promotionCode: string; amount: number };
86
+ }) => Promise<GrantPromotionRewardForGameResponse>;
81
87
  submitGameCenterLeaderBoardScore: (params: { score: string }) => Promise<SubmitGameCenterLeaderBoardScoreResponse>;
82
88
 
83
89
  contactsViral: (params: ContactsViralParams) => () => void;
@@ -0,0 +1,125 @@
1
+ import { AppsInTossModule } from './AppsInTossModule';
2
+ import { isMinVersionSupported } from './isMinVersionSupported';
3
+ import { GAME_USER_KEY_MIN_VERSION } from '../constants';
4
+
5
+ export interface GetUserKeyForGameSuccessResponse {
6
+ hash: string;
7
+ type: 'HASH';
8
+ }
9
+
10
+ export interface GetUserKeyForGameErrorResponse {
11
+ type: 'NOT_AVAILABLE';
12
+ }
13
+
14
+ export type GetUserKeyForGameResponse = GetUserKeyForGameSuccessResponse | GetUserKeyForGameErrorResponse;
15
+
16
+ /**
17
+ * @public
18
+ * @category 게임
19
+ * @name getUserKeyForGame
20
+ * @description
21
+ * 게임 카테고리 미니앱에서 사용자의 고유 키를 가져와요. 이 키를 사용해서 사용자를 식별하고 게임 데이터를 관리할 수 있어요.
22
+ * 게임 카테고리가 아닌 미니앱에서 호출하면 `'INVALID_CATEGORY'`를 반환해요.
23
+ * @returns {Promise<GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined>}
24
+ * 사용자 키 조회 결과를 반환해요.
25
+ * - `GetUserKeyForGameSuccessResponse`: 사용자 키 조회에 성공했어요. `{ type: 'HASH', hash: string }` 형태로 반환돼요.
26
+ * - `'INVALID_CATEGORY'`: 게임 카테고리가 아닌 미니앱에서 호출했어요.
27
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
28
+ * - `undefined`: 앱 버전이 최소 지원 버전보다 낮아요.
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * // react-native
33
+ * import { Button } from 'react-native';
34
+ * import { getUserKeyForGame } from '@apps-in-toss/framework';
35
+ *
36
+ * function GameUserKeyButton() {
37
+ * async function handlePress() {
38
+ * const result = await getUserKeyForGame();
39
+ *
40
+ * if (!result) {
41
+ * console.warn('지원하지 않는 앱 버전이에요.');
42
+ * return;
43
+ * }
44
+ *
45
+ * if (result === 'INVALID_CATEGORY') {
46
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
47
+ * return;
48
+ * }
49
+ *
50
+ * if (result === 'ERROR') {
51
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
52
+ * return;
53
+ * }
54
+ *
55
+ * if (result.type === 'HASH') {
56
+ * console.log('사용자 키:', result.hash);
57
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
58
+ * }
59
+ * }
60
+ *
61
+ * return (
62
+ * <Button onPress={handlePress} title="유저 키 가져오기" />
63
+ * );
64
+ * }
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * // webview
70
+ * import { getUserKeyForGame } from '@apps-in-toss/web-framework';
71
+ *
72
+ * function GameUserKeyButton() {
73
+ * async function handleClick() {
74
+ * const result = await getUserKeyForGame();
75
+ *
76
+ * if (!result) {
77
+ * console.warn('지원하지 않는 앱 버전이에요.');
78
+ * return;
79
+ * }
80
+ *
81
+ * if (result === 'INVALID_CATEGORY') {
82
+ * console.error('게임 카테고리가 아닌 미니앱이에요.');
83
+ * return;
84
+ * }
85
+ *
86
+ * if (result === 'ERROR') {
87
+ * console.error('사용자 키 조회 중 오류가 발생했어요.');
88
+ * return;
89
+ * }
90
+ *
91
+ * if (result.type === 'HASH') {
92
+ * console.log('사용자 키:', result.hash);
93
+ * // 여기에서 사용자 키를 사용해 게임 데이터를 관리할 수 있어요.
94
+ * }
95
+ * }
96
+ *
97
+ * return (
98
+ * <button onClick={handleClick}>유저 키 가져오기</button>
99
+ * );
100
+ * }
101
+ * ```
102
+ */
103
+ export async function getUserKeyForGame(): Promise<
104
+ GetUserKeyForGameSuccessResponse | 'INVALID_CATEGORY' | 'ERROR' | undefined
105
+ > {
106
+ const isSupported = isMinVersionSupported(GAME_USER_KEY_MIN_VERSION);
107
+
108
+ if (!isSupported) {
109
+ return;
110
+ }
111
+
112
+ try {
113
+ const response = await AppsInTossModule.getUserKeyForGame({});
114
+ if (response.type === 'HASH') {
115
+ return response;
116
+ }
117
+ if (response.type === 'NOT_AVAILABLE') {
118
+ return 'INVALID_CATEGORY';
119
+ }
120
+ return 'ERROR';
121
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
+ } catch (_) {
123
+ return 'ERROR';
124
+ }
125
+ }
@@ -0,0 +1,165 @@
1
+ import { AppsInTossModule } from './AppsInTossModule';
2
+ import { isMinVersionSupported } from './isMinVersionSupported';
3
+ import { GAME_PROMOTION_REWARD_MIN_VERSION } from '../constants';
4
+
5
+ export interface GrantPromotionRewardForGameSuccessResponse {
6
+ key: string;
7
+ }
8
+
9
+ export interface GrantPromotionRewardForGameErrorResponse {
10
+ code: string;
11
+ [key: string]: any;
12
+ }
13
+
14
+ export interface GrantPromotionRewardForGameErrorResult {
15
+ errorCode: string;
16
+ message: string;
17
+ }
18
+
19
+ export type GrantPromotionRewardForGameResponse =
20
+ | GrantPromotionRewardForGameSuccessResponse
21
+ | GrantPromotionRewardForGameErrorResponse;
22
+
23
+ type GrantPromotionRewardForGameResult =
24
+ | GrantPromotionRewardForGameResponse
25
+ | GrantPromotionRewardForGameErrorResult
26
+ | 'ERROR'
27
+ | undefined;
28
+
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
+ /**
41
+ * @public
42
+ * @category 게임
43
+ * @name grantPromotionRewardForGame
44
+ * @description
45
+ * 이 함수를 사용하면 게임 카테고리 미니앱에서 프로모션 코드를 사용해서 유저에게 리워드를 지급할 수 있어요.
46
+ * 게임 카테고리가 아닌 미니앱에서 호출할 수 없어요.
47
+ * @param {{ params: { promotionCode: string; amount: number } }} params - 포인트를 지급하기 위해 필요한 정보예요.
48
+ * @param {string} params.promotionCode - 프로모션 코드예요.
49
+ * @param {number} params.amount - 지급할 포인트 금액이에요.
50
+ * @returns {Promise<{ key: string } | { errorCode: string; message: string } | 'ERROR' | undefined>}
51
+ * 포인트 지급 결과를 반환해요.
52
+ * - `{ key: string }`: 포인트 지급에 성공했어요. key는 리워드 키를 의미해요.
53
+ * - `{ errorCode: string, message: string }`: 포인트 지급에 실패했어요. 에러 코드는 다음과 같아요.
54
+ * - `"40000"`: 게임이 아닌 미니앱에서 호출했을 때
55
+ * - `"4100"`: 프로모션 정보를 찾을 수 없을 때
56
+ * - `"4104"`: 프로모션이 중지되었을 때
57
+ * - `"4105"`: 프로모션이 종료되었을 때
58
+ * - `"4108"`: 프로모션이 승인되지 않았을 때
59
+ * - `"4109"`: 프로모션이 실행중이 아닐 때
60
+ * - `"4110"`: 리워드를 지급/회수할 수 없을 때
61
+ * - `"4112"`: 프로모션 머니가 부족할 때
62
+ * - `"4113"`: 이미 지급/회수된 내역일 때
63
+ * - `"4114"`: 프로모션에 설정된 1회 지급 금액을 초과할 때
64
+ * - `'ERROR'`: 알 수 없는 오류가 발생했어요.
65
+ * - `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
+ *
102
+ * @example
103
+ * ```tsx
104
+ * // webview
105
+ * import { grantPromotionRewardForGame } from '@apps-in-toss/web-framework';
106
+ *
107
+ * function GrantRewardButton() {
108
+ * async function handleClick() {
109
+ * const result = await grantPromotionRewardForGame({
110
+ * params: {
111
+ * promotionCode: 'GAME_EVENT_2024',
112
+ * amount: 1000,
113
+ * },
114
+ * });
115
+ *
116
+ * if (!result) {
117
+ * console.warn('지원하지 않는 앱 버전이에요.');
118
+ * return;
119
+ * }
120
+ *
121
+ * if (result === 'ERROR') {
122
+ * console.error('포인트 지급 중 알 수 없는 오류가 발생했어요.');
123
+ * return;
124
+ * }
125
+ *
126
+ * if ('key' in result) {
127
+ * console.log('포인트 지급 성공!', result.key);
128
+ * } else if ('errorCode' in result) {
129
+ * console.error('포인트 지급 실패:', result.errorCode, result.message);
130
+ * }
131
+ * }
132
+ *
133
+ * return (
134
+ * <button onClick={handleClick}>포인트 지급하기</button>
135
+ * );
136
+ * }
137
+ * ```
138
+ */
139
+ export async function grantPromotionRewardForGame({
140
+ params,
141
+ }: {
142
+ params: { promotionCode: string; amount: number };
143
+ }): Promise<GrantPromotionRewardForGameResult> {
144
+ const isSupported = isMinVersionSupported(GAME_PROMOTION_REWARD_MIN_VERSION);
145
+
146
+ if (!isSupported) {
147
+ return;
148
+ }
149
+
150
+ try {
151
+ const response = await AppsInTossModule.grantPromotionRewardForGame({ params });
152
+ if (response.key) {
153
+ return response;
154
+ }
155
+ return 'ERROR';
156
+ } catch (error) {
157
+ if (isGrantPromotionRewardForGameError(error)) {
158
+ return {
159
+ errorCode: error.code,
160
+ message: error.message,
161
+ };
162
+ }
163
+ return 'ERROR';
164
+ }
165
+ }
@@ -53,6 +53,8 @@ export * from './storage';
53
53
  export * from './openGameCenterLeaderboard';
54
54
  export * from './getGameCenterGameProfile';
55
55
  export * from './submitGameCenterLeaderBoardScore';
56
+ export * from './getUserKeyForGame';
57
+ export * from './grantPromotionRewardForGame';
56
58
  export * from '../native-event-emitter/contactsViral';
57
59
  export * from './appsInTossSignTossCert';
58
60
 
@@ -28,3 +28,5 @@ export * from './AppsInTossModule/native-modules/appsInTossSignTossCert';
28
28
  export * from './AppsInTossModule/native-modules/getGameCenterGameProfile';
29
29
  export * from './AppsInTossModule/native-modules/openGameCenterLeaderboard';
30
30
  export * from './AppsInTossModule/native-modules/submitGameCenterLeaderBoardScore';
31
+ export * from './AppsInTossModule/native-modules/getUserKeyForGame';
32
+ export * from './AppsInTossModule/native-modules/grantPromotionRewardForGame';