@apps-in-toss/framework 0.0.28 → 0.0.29
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.
- package/dist/index.cjs +103 -19
- package/dist/index.d.cts +219 -2
- package/dist/index.d.ts +219 -2
- package/dist/index.js +85 -4
- package/package.json +5 -5
- package/src/async-bridges.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(src_exports, {
|
|
|
35
35
|
Analytics: () => Analytics2,
|
|
36
36
|
AppsInToss: () => AppsInToss,
|
|
37
37
|
GoogleAdMob: () => GoogleAdMob,
|
|
38
|
+
IAP: () => IAP,
|
|
39
|
+
INTERNAL__onVisibilityChangedByTransparentServiceWeb: () => INTERNAL__onVisibilityChangedByTransparentServiceWeb,
|
|
38
40
|
Storage: () => Storage,
|
|
39
41
|
TossPay: () => TossPay,
|
|
40
42
|
WebView: () => WebView,
|
|
@@ -52,6 +54,7 @@ __export(src_exports, {
|
|
|
52
54
|
getTossShareLink: () => getTossShareLink,
|
|
53
55
|
isMinVersionSupported: () => isMinVersionSupported,
|
|
54
56
|
openCamera: () => openCamera,
|
|
57
|
+
saveBase64Data: () => saveBase64Data,
|
|
55
58
|
setClipboardText: () => setClipboardText,
|
|
56
59
|
setDeviceOrientation: () => setDeviceOrientation,
|
|
57
60
|
startUpdateLocation: () => startUpdateLocation,
|
|
@@ -63,7 +66,7 @@ var import_analytics2 = require("@apps-in-toss/analytics");
|
|
|
63
66
|
// src/core/registerApp.tsx
|
|
64
67
|
var import_analytics = require("@apps-in-toss/analytics");
|
|
65
68
|
var import_react_native6 = require("@toss-design-system/react-native");
|
|
66
|
-
var
|
|
69
|
+
var import_react_native_bedrock8 = require("react-native-bedrock");
|
|
67
70
|
|
|
68
71
|
// src/core/components/AppEvent.tsx
|
|
69
72
|
var import_react2 = require("react");
|
|
@@ -261,7 +264,7 @@ var import_react_native5 = require("@toss-design-system/react-native");
|
|
|
261
264
|
var import_react3 = require("react");
|
|
262
265
|
|
|
263
266
|
// src/native-event-emitter/appsInTossEvent.ts
|
|
264
|
-
var
|
|
267
|
+
var import_react_native_bedrock7 = require("react-native-bedrock");
|
|
265
268
|
|
|
266
269
|
// src/native-event-emitter/event-plugins/EntryMessageExitedEvent.ts
|
|
267
270
|
var import_react_native_bedrock3 = require("react-native-bedrock");
|
|
@@ -420,11 +423,39 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends import_react_
|
|
|
420
423
|
}
|
|
421
424
|
};
|
|
422
425
|
|
|
426
|
+
// src/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
|
|
427
|
+
var import_react_native_bedrock6 = require("react-native-bedrock");
|
|
428
|
+
var VisibilityChangedByTransparentServiceWebEvent = class extends import_react_native_bedrock6.BedrockEventDefinition {
|
|
429
|
+
name = "onVisibilityChangedByTransparentServiceWeb";
|
|
430
|
+
subscription = null;
|
|
431
|
+
remove() {
|
|
432
|
+
this.subscription?.remove();
|
|
433
|
+
this.subscription = null;
|
|
434
|
+
}
|
|
435
|
+
listener(options, onEvent, onError) {
|
|
436
|
+
const subscription = nativeEventEmitter.addListener("visibilityChangedByTransparentServiceWeb", (params) => {
|
|
437
|
+
if (this.isVisibilityChangedByTransparentServiceWebResult(params)) {
|
|
438
|
+
if (params.callbackId === options.callbackId) {
|
|
439
|
+
onEvent(params.isVisible);
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
onError(new Error("Invalid visibility changed by transparent service web result"));
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
this.subscription = subscription;
|
|
446
|
+
}
|
|
447
|
+
isVisibilityChangedByTransparentServiceWebResult(params) {
|
|
448
|
+
return typeof params === "object" && typeof params.callbackId === "string" && typeof params.isVisible === "boolean";
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
|
|
423
452
|
// src/native-event-emitter/appsInTossEvent.ts
|
|
424
|
-
var appsInTossEvent = new
|
|
425
|
-
new AppBridgeCallbackEvent(),
|
|
453
|
+
var appsInTossEvent = new import_react_native_bedrock7.BedrockEvent([
|
|
426
454
|
new UpdateLocationEvent(),
|
|
427
|
-
new EntryMessageExitedEvent()
|
|
455
|
+
new EntryMessageExitedEvent(),
|
|
456
|
+
// Internal events
|
|
457
|
+
new AppBridgeCallbackEvent(),
|
|
458
|
+
new VisibilityChangedByTransparentServiceWebEvent()
|
|
428
459
|
]);
|
|
429
460
|
|
|
430
461
|
// src/core/utils/getAppsInTossGlobals.ts
|
|
@@ -472,6 +503,7 @@ __export(async_bridges_exports, {
|
|
|
472
503
|
getCurrentLocation: () => getCurrentLocation,
|
|
473
504
|
getTossShareLink: () => getTossShareLink,
|
|
474
505
|
openCamera: () => openCamera,
|
|
506
|
+
saveBase64Data: () => saveBase64Data,
|
|
475
507
|
setClipboardText: () => setClipboardText,
|
|
476
508
|
setDeviceOrientation: () => setDeviceOrientation
|
|
477
509
|
});
|
|
@@ -612,6 +644,19 @@ async function setDeviceOrientation(options) {
|
|
|
612
644
|
return AppsInTossModule.setDeviceOrientation(options);
|
|
613
645
|
}
|
|
614
646
|
|
|
647
|
+
// src/native-modules/saveBase64Data.ts
|
|
648
|
+
async function saveBase64Data(params) {
|
|
649
|
+
const isSupported = isMinVersionSupported({
|
|
650
|
+
android: "5.218.0",
|
|
651
|
+
ios: "5.216.0"
|
|
652
|
+
});
|
|
653
|
+
if (!isSupported) {
|
|
654
|
+
console.warn("saveBase64Data is not supported in this app version");
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
await AppsInTossModule.saveBase64Data(params);
|
|
658
|
+
}
|
|
659
|
+
|
|
615
660
|
// src/core/registerApp.tsx
|
|
616
661
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
617
662
|
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
@@ -630,7 +675,7 @@ function registerApp(container, { context, analytics }) {
|
|
|
630
675
|
logger: (params) => void eventLog(params),
|
|
631
676
|
debug: analytics?.debug ?? __DEV__
|
|
632
677
|
});
|
|
633
|
-
return
|
|
678
|
+
return import_react_native_bedrock8.Bedrock.registerApp(AppsInTossContainer.bind(null, container), {
|
|
634
679
|
appName: getAppName(),
|
|
635
680
|
context,
|
|
636
681
|
router: {
|
|
@@ -753,7 +798,6 @@ var ENVIRONMENT = getOperationalEnvironment();
|
|
|
753
798
|
function createIsSupported() {
|
|
754
799
|
return () => {
|
|
755
800
|
if (ENVIRONMENT !== "toss") {
|
|
756
|
-
console.warn("Google AdMob is not supported in the current environment");
|
|
757
801
|
return false;
|
|
758
802
|
}
|
|
759
803
|
return isMinVersionSupported({
|
|
@@ -800,6 +844,32 @@ var Storage = {
|
|
|
800
844
|
clearItems
|
|
801
845
|
};
|
|
802
846
|
|
|
847
|
+
// src/native-modules/iap.ts
|
|
848
|
+
async function createOneTimePurchaseOrder(params) {
|
|
849
|
+
const isSupported = isMinVersionSupported({
|
|
850
|
+
android: "5.219.0",
|
|
851
|
+
ios: "5.219.0"
|
|
852
|
+
});
|
|
853
|
+
if (!isSupported) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
return AppsInTossModule.iapCreateOneTimePurchaseOrder(params);
|
|
857
|
+
}
|
|
858
|
+
async function getProductItemList() {
|
|
859
|
+
const isSupported = isMinVersionSupported({
|
|
860
|
+
android: "5.219.0",
|
|
861
|
+
ios: "5.219.0"
|
|
862
|
+
});
|
|
863
|
+
if (!isSupported) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
return AppsInTossModule.iapGetProductItemList({});
|
|
867
|
+
}
|
|
868
|
+
var IAP = {
|
|
869
|
+
createOneTimePurchaseOrder,
|
|
870
|
+
getProductItemList
|
|
871
|
+
};
|
|
872
|
+
|
|
803
873
|
// src/native-modules/index.ts
|
|
804
874
|
var TossPay = {
|
|
805
875
|
checkoutPayment
|
|
@@ -815,7 +885,7 @@ var GoogleAdMob = {
|
|
|
815
885
|
var import_react_native14 = require("@toss-design-system/react-native");
|
|
816
886
|
var import_private = require("@toss-design-system/react-native/private");
|
|
817
887
|
var import_react6 = require("react");
|
|
818
|
-
var
|
|
888
|
+
var import_react_native_bedrock11 = require("react-native-bedrock");
|
|
819
889
|
var bedrockAsyncBridges = __toESM(require("react-native-bedrock/async-bridges"), 1);
|
|
820
890
|
var bedrockConstantBridges = __toESM(require("react-native-bedrock/constant-bridges"), 1);
|
|
821
891
|
|
|
@@ -825,7 +895,7 @@ var import_react_native12 = require("@toss-design-system/react-native");
|
|
|
825
895
|
var import_es_hangul = require("es-hangul");
|
|
826
896
|
var import_react4 = require("react");
|
|
827
897
|
var import_react_native13 = require("react-native");
|
|
828
|
-
var
|
|
898
|
+
var import_react_native_bedrock9 = require("react-native-bedrock");
|
|
829
899
|
|
|
830
900
|
// src/components/GameWebViewNavigationBar/GameNavigationBar.tsx
|
|
831
901
|
var import_react_native_svg = require("@react-native-bedrock/native/react-native-svg");
|
|
@@ -936,14 +1006,14 @@ var GameWebView = (0, import_react4.forwardRef)(function GameWebView2(props, ref
|
|
|
936
1006
|
closeOnDimmerClick: true
|
|
937
1007
|
});
|
|
938
1008
|
if (isConfirmed) {
|
|
939
|
-
(0,
|
|
1009
|
+
(0, import_react_native_bedrock9.closeView)();
|
|
940
1010
|
}
|
|
941
1011
|
}, [brandDisplayName, openConfirm]);
|
|
942
1012
|
(0, import_react4.useEffect)(() => {
|
|
943
1013
|
if (import_react_native13.Platform.OS === "ios") {
|
|
944
|
-
(0,
|
|
1014
|
+
(0, import_react_native_bedrock9.setIosSwipeGestureEnabled)({ isEnabled: false });
|
|
945
1015
|
return () => {
|
|
946
|
-
(0,
|
|
1016
|
+
(0, import_react_native_bedrock9.setIosSwipeGestureEnabled)({ isEnabled: true });
|
|
947
1017
|
};
|
|
948
1018
|
}
|
|
949
1019
|
return;
|
|
@@ -1106,7 +1176,7 @@ __export(event_bridges_exports, {
|
|
|
1106
1176
|
});
|
|
1107
1177
|
|
|
1108
1178
|
// src/utils/log.ts
|
|
1109
|
-
var
|
|
1179
|
+
var import_react_native_bedrock10 = require("react-native-bedrock");
|
|
1110
1180
|
|
|
1111
1181
|
// src/utils/extractDateFromUUIDv7.ts
|
|
1112
1182
|
var extractDateFromUUIDv7 = (uuid) => {
|
|
@@ -1132,7 +1202,7 @@ var getGroupId = (url) => {
|
|
|
1132
1202
|
};
|
|
1133
1203
|
var getReferrer = () => {
|
|
1134
1204
|
try {
|
|
1135
|
-
const referrer = new URL((0,
|
|
1205
|
+
const referrer = new URL((0, import_react_native_bedrock10.getSchemeUri)());
|
|
1136
1206
|
return referrer.searchParams.get("referrer");
|
|
1137
1207
|
} catch {
|
|
1138
1208
|
return "";
|
|
@@ -1165,7 +1235,7 @@ var WEBVIEW_TYPES = {
|
|
|
1165
1235
|
};
|
|
1166
1236
|
function mergeSchemeQueryParamsInto(url) {
|
|
1167
1237
|
const baseUrl = new URL(url);
|
|
1168
|
-
const schemeUrl = new URL((0,
|
|
1238
|
+
const schemeUrl = new URL((0, import_react_native_bedrock11.getSchemeUri)());
|
|
1169
1239
|
baseUrl.pathname = schemeUrl.pathname;
|
|
1170
1240
|
for (const [key, value] of schemeUrl.searchParams.entries()) {
|
|
1171
1241
|
baseUrl.searchParams.set(key, value);
|
|
@@ -1189,7 +1259,7 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1189
1259
|
if (!TYPES.includes(type)) {
|
|
1190
1260
|
throw new Error(`Invalid WebView type: '${type}'`);
|
|
1191
1261
|
}
|
|
1192
|
-
const bedrockEvent = (0,
|
|
1262
|
+
const bedrockEvent = (0, import_react_native_bedrock11.useBedrockEvent)();
|
|
1193
1263
|
const uri = (0, import_react6.useMemo)(() => getWebViewUri(local), [local]);
|
|
1194
1264
|
const top = (0, import_private.useSafeAreaTop)();
|
|
1195
1265
|
const bottom = (0, import_private.useSafeAreaBottom)();
|
|
@@ -1231,7 +1301,10 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1231
1301
|
getStorageItem: Storage.getItem,
|
|
1232
1302
|
setStorageItem: Storage.setItem,
|
|
1233
1303
|
removeStorageItem: Storage.removeItem,
|
|
1234
|
-
clearItems: Storage.clearItems
|
|
1304
|
+
clearItems: Storage.clearItems,
|
|
1305
|
+
/** IAP */
|
|
1306
|
+
iapCreateOneTimePurchaseOrder: IAP.createOneTimePurchaseOrder,
|
|
1307
|
+
iapGetProductItemList: IAP.getProductItemList
|
|
1235
1308
|
}
|
|
1236
1309
|
});
|
|
1237
1310
|
const baseProps = (0, import_react6.useMemo)(() => {
|
|
@@ -1296,9 +1369,9 @@ function ensureValue(value, name) {
|
|
|
1296
1369
|
|
|
1297
1370
|
// src/hooks/useGeolocation.ts
|
|
1298
1371
|
var import_react7 = require("react");
|
|
1299
|
-
var
|
|
1372
|
+
var import_react_native_bedrock12 = require("react-native-bedrock");
|
|
1300
1373
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
1301
|
-
const isVisible = (0,
|
|
1374
|
+
const isVisible = (0, import_react_native_bedrock12.useVisibility)();
|
|
1302
1375
|
const [location, setLocation] = (0, import_react7.useState)(null);
|
|
1303
1376
|
(0, import_react7.useEffect)(() => {
|
|
1304
1377
|
if (!isVisible) {
|
|
@@ -1328,6 +1401,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
1328
1401
|
return Accuracy3;
|
|
1329
1402
|
})(Accuracy2 || {});
|
|
1330
1403
|
|
|
1404
|
+
// src/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
|
|
1405
|
+
function onVisibilityChangedByTransparentServiceWeb(eventParams) {
|
|
1406
|
+
return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
// src/private.ts
|
|
1410
|
+
var INTERNAL__onVisibilityChangedByTransparentServiceWeb = onVisibilityChangedByTransparentServiceWeb;
|
|
1411
|
+
|
|
1331
1412
|
// src/index.ts
|
|
1332
1413
|
__reExport(src_exports, require("@apps-in-toss/analytics"), module.exports);
|
|
1333
1414
|
var Analytics2 = {
|
|
@@ -1342,6 +1423,8 @@ var Analytics2 = {
|
|
|
1342
1423
|
Analytics,
|
|
1343
1424
|
AppsInToss,
|
|
1344
1425
|
GoogleAdMob,
|
|
1426
|
+
IAP,
|
|
1427
|
+
INTERNAL__onVisibilityChangedByTransparentServiceWeb,
|
|
1345
1428
|
Storage,
|
|
1346
1429
|
TossPay,
|
|
1347
1430
|
WebView,
|
|
@@ -1359,6 +1442,7 @@ var Analytics2 = {
|
|
|
1359
1442
|
getTossShareLink,
|
|
1360
1443
|
isMinVersionSupported,
|
|
1361
1444
|
openCamera,
|
|
1445
|
+
saveBase64Data,
|
|
1362
1446
|
setClipboardText,
|
|
1363
1447
|
setDeviceOrientation,
|
|
1364
1448
|
startUpdateLocation,
|
package/dist/index.d.cts
CHANGED
|
@@ -1716,6 +1716,204 @@ declare function setDeviceOrientation(options: {
|
|
|
1716
1716
|
type: 'portrait' | 'landscape';
|
|
1717
1717
|
}): Promise<void>;
|
|
1718
1718
|
|
|
1719
|
+
interface SaveBase64DataParams {
|
|
1720
|
+
data: string;
|
|
1721
|
+
fileName: string;
|
|
1722
|
+
mimeType: string;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* @public
|
|
1726
|
+
* @category 데이터
|
|
1727
|
+
* @name saveBase64Data
|
|
1728
|
+
* @description 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요.
|
|
1729
|
+
* @param {SaveBase64DataParams} params - 저장할 데이터와 파일 정보를 담은 객체예요.
|
|
1730
|
+
* @param {string} params.data - Base64 형식으로 인코딩된 데이터 문자열이에요.
|
|
1731
|
+
* @param {string} params.fileName - 저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요.
|
|
1732
|
+
* @param {string} params.mimeType - 저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요.
|
|
1733
|
+
*
|
|
1734
|
+
* @example
|
|
1735
|
+
* ### Base64 이미지 데이터를 사용자 기기에 저장하기
|
|
1736
|
+
*
|
|
1737
|
+
* ```tsx
|
|
1738
|
+
* import { Button } from 'react-native';
|
|
1739
|
+
* import { saveBase64Data } from '@apps-in-toss/framework';
|
|
1740
|
+
*
|
|
1741
|
+
* // '저장' 버튼을 누르면 이미지가 사용자 기기에 저장돼요.
|
|
1742
|
+
* function SaveButton() {
|
|
1743
|
+
* const handleSave = async () => {
|
|
1744
|
+
* try {
|
|
1745
|
+
* await saveBase64Data({
|
|
1746
|
+
* data: 'iVBORw0KGgo...',
|
|
1747
|
+
* fileName: 'some-photo.png',
|
|
1748
|
+
* mimeType: 'image/png',
|
|
1749
|
+
* });
|
|
1750
|
+
* } catch (error) {
|
|
1751
|
+
* console.error('데이터 저장에 실패했어요:', error);
|
|
1752
|
+
* }
|
|
1753
|
+
* };
|
|
1754
|
+
*
|
|
1755
|
+
* return <Button title="저장" onPress={handleSave} />;
|
|
1756
|
+
* }
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
declare function saveBase64Data(params: SaveBase64DataParams): Promise<void>;
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* @public
|
|
1763
|
+
* @category 인앱결제
|
|
1764
|
+
* @name IapCreateOneTimePurchaseOrderOptions
|
|
1765
|
+
* @description 인앱결제 1건을 요청할 때 필요한 정보예요.
|
|
1766
|
+
* @property {string} productId - 주문할 상품의 ID예요.
|
|
1767
|
+
*/
|
|
1768
|
+
interface IapCreateOneTimePurchaseOrderOptions {
|
|
1769
|
+
productId: string;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* @public
|
|
1773
|
+
* @category 인앱결제
|
|
1774
|
+
* @name IapCreateOneTimePurchaseOrderResult
|
|
1775
|
+
* @description 인앱결제 1건이 완료되면 결제 세부 정보와 상품 정보를 담아 반환해요. 반환된 정보로 결제한 상품의 정보를 화면에 표시할 수 있어요.
|
|
1776
|
+
* @property {string | null} miniAppIconUrl - 미니앱 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. 콘솔에서 아이콘을 등록하지 않았다면 `null`로 반환돼요.
|
|
1777
|
+
* @property {string} displayName - 화면에 표시할 상품 이름이에요.
|
|
1778
|
+
* @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
|
|
1779
|
+
* @property {number} amount - 상품 가격 숫자 값이에요. 화폐 단위와 쉼표를 제외한 순수 숫자예요. 예를 들어 `1000`으로 표시돼요.
|
|
1780
|
+
* @property {string} currency - [ISO 4217 표준](https://ko.wikipedia.org/wiki/ISO_4217)에 따른 상품 가격 통화 단위예요. 예를 들어 원화는 `KRW`, 달러는 `USD`로 표시돼요.
|
|
1781
|
+
* @property {number} fraction - 가격을 표시할 때 소수점 아래 몇 자리까지 보여줄지 정하는 값이에요. 예를 들어 달러는 소수점 둘째 자리까지 보여줘서 `2`, 원화는 소수점이 필요 없어서 `0`이에요
|
|
1782
|
+
*/
|
|
1783
|
+
interface IapCreateOneTimePurchaseOrderResult {
|
|
1784
|
+
miniAppIconUrl: string | null;
|
|
1785
|
+
displayName: string;
|
|
1786
|
+
displayAmount: string;
|
|
1787
|
+
amount: number;
|
|
1788
|
+
currency: string;
|
|
1789
|
+
fraction: number;
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* @public
|
|
1793
|
+
* @category 인앱결제
|
|
1794
|
+
* @name iapCreateOneTimePurchaseOrder
|
|
1795
|
+
* @description
|
|
1796
|
+
* 특정 인앱결제 주문서 페이지로 이동해요. 사용자가 상품 구매 버튼을 누르는 상황 등에 사용할 수 있어요. 사용자의 결제는 이동한 페이지에서 진행돼요. 만약 결제 중에 에러가 발생하면 에러 유형에 따라 에러 페이지로 이동해요.
|
|
1797
|
+
* @param {IapCreateOneTimePurchaseOrderOptions} params - 인앱결제를 생성할 때 필요한 정보예요.
|
|
1798
|
+
* @param {string} params.productId - 주문할 상품의 ID예요.
|
|
1799
|
+
* @returns {Promise<IapCreateOneTimePurchaseOrderResult | undefined>} 결제에 성공하면 결제 결과 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 인앱결제를 실행할 수 없어서 `undefined`를 반환해요.
|
|
1800
|
+
*
|
|
1801
|
+
* @throw {code: "INVALID_PRODUCT_ID"} - 유효하지 않은 상품 ID이거나, 해당 상품이 존재하지 않을 때 발생해요.
|
|
1802
|
+
* @throw {code: "PAYMENT_PENDING"} - 사용자가 요청한 결제가 아직 승인을 기다리고 있을 때 발생해요.
|
|
1803
|
+
* @throw {code: "NETWORK_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
|
|
1804
|
+
* @throw {code: "INVALID_USER_ENVIRONMENT"} - 특정 기기, 계정 또는 설정 환경에서 구매할 수 없는 상품일 때 발생해요.
|
|
1805
|
+
* @throw {code: "ITEM_ALREADY_OWNED"} - 사용자가 이미 구매한 상품을 다시 구매하려고 할 때 발생해요.
|
|
1806
|
+
* @throw {code: "APP_MARKET_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 앱스토어에서 사용자 정보 검증에 실패했을 때 발생해요. 사용자가 앱스토어에 문의해서 환불을 요청해야해요.
|
|
1807
|
+
* @throw {code: "TOSS_SERVER_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 서버 전송에 실패해서 결제 정보를 저장할 수 없을 때 발생해요.
|
|
1808
|
+
* @throw {code: "INTERNAL_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
|
|
1809
|
+
* @throw {code: "KOREAN_ACCOUNT_ONLY"} - iOS 환경에서 사용자의 계정이 한국 계정이 아닐 때 발생해요.
|
|
1810
|
+
* @throw {code: "USER_CANCELED"} - 사용자가 결제를 완료하지 않고 주문서 페이지를 이탈했을 때 발생해요.
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
* ### 특정 인앱결제 주문서 페이지로 이동하기
|
|
1814
|
+
*
|
|
1815
|
+
* ```tsx
|
|
1816
|
+
* import { Button } from 'react-native';
|
|
1817
|
+
* import { IAP } from '@apps-in-toss/framework';
|
|
1818
|
+
*
|
|
1819
|
+
* interface Props {
|
|
1820
|
+
* productId: string;
|
|
1821
|
+
* }
|
|
1822
|
+
*
|
|
1823
|
+
* function IapCreateOneTimePurchaseOrderButton({ productId }: Props) {
|
|
1824
|
+
* const handleClick = async () => {
|
|
1825
|
+
* try {
|
|
1826
|
+
* await IAP.createOneTimePurchaseOrder({
|
|
1827
|
+
* productId,
|
|
1828
|
+
* });
|
|
1829
|
+
* } catch (error) {
|
|
1830
|
+
* console.error('인앱결제에 실패했어요:', error);
|
|
1831
|
+
* }
|
|
1832
|
+
* };
|
|
1833
|
+
*
|
|
1834
|
+
* return <Button title="구매하기" onPress={handleClick} />;
|
|
1835
|
+
* }
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
declare function createOneTimePurchaseOrder(params: IapCreateOneTimePurchaseOrderOptions): Promise<IapCreateOneTimePurchaseOrderResult | undefined>;
|
|
1839
|
+
/**
|
|
1840
|
+
* @public
|
|
1841
|
+
* @category 인앱결제
|
|
1842
|
+
* @name IapProductListItem
|
|
1843
|
+
* @description 인앱결제로 구매할 수 있는 상품 하나의 정보를 담은 객체예요. 상품 목록을 화면에 표시할 때 사용해요.
|
|
1844
|
+
* @property {string} sku - 상품의 고유 ID예요. [인앱결제 주문서 페이지로 이동할때](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 사용하는 `productId`와 동일한 값이에요.
|
|
1845
|
+
* @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요.
|
|
1846
|
+
* @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
|
|
1847
|
+
* @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요.
|
|
1848
|
+
* @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요.
|
|
1849
|
+
*/
|
|
1850
|
+
interface IapProductListItem {
|
|
1851
|
+
sku: string;
|
|
1852
|
+
displayAmount: string;
|
|
1853
|
+
displayName: string;
|
|
1854
|
+
iconUrl: string;
|
|
1855
|
+
description: string;
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* @public
|
|
1859
|
+
* @category 인앱결제
|
|
1860
|
+
* @name iapGetProductItemList
|
|
1861
|
+
* @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요.
|
|
1862
|
+
* @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요.
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ### 구매 가능한 인앱결제 상품목록 가져오기
|
|
1866
|
+
*
|
|
1867
|
+
* ```tsx
|
|
1868
|
+
* import { useEffect, useState } from 'react';
|
|
1869
|
+
* import { List, ListRow, Txt } from '@toss-design-system/react-native';
|
|
1870
|
+
* import { IAP } from '@apps-in-toss/framework';
|
|
1871
|
+
*
|
|
1872
|
+
* function IapGetProductItemList() {
|
|
1873
|
+
* const [products, setProducts] = useState<IapProductListItem[]>([]);
|
|
1874
|
+
*
|
|
1875
|
+
* useEffect(() => {
|
|
1876
|
+
* async function fetchProducts() {
|
|
1877
|
+
* try {
|
|
1878
|
+
* const response = await IAP.getProductItemList();
|
|
1879
|
+
* setProducts(response?.products ?? []);
|
|
1880
|
+
* } catch (error) {
|
|
1881
|
+
* console.error('상품 목록을 가져오는 데 실패했어요:', error);
|
|
1882
|
+
* }
|
|
1883
|
+
* }
|
|
1884
|
+
*
|
|
1885
|
+
* fetchProducts();
|
|
1886
|
+
* }, []);
|
|
1887
|
+
*
|
|
1888
|
+
* return (
|
|
1889
|
+
* <List>
|
|
1890
|
+
* {products.map((product) => (
|
|
1891
|
+
* <ListRow
|
|
1892
|
+
* key={product.sku}
|
|
1893
|
+
* contents={<Txt>{product.displayName}</Txt>}
|
|
1894
|
+
* />
|
|
1895
|
+
* ))}
|
|
1896
|
+
* </List>
|
|
1897
|
+
* );
|
|
1898
|
+
* }
|
|
1899
|
+
* ```
|
|
1900
|
+
*/
|
|
1901
|
+
declare function getProductItemList(): Promise<{
|
|
1902
|
+
products: IapProductListItem[];
|
|
1903
|
+
} | undefined>;
|
|
1904
|
+
/**
|
|
1905
|
+
* @public
|
|
1906
|
+
* @category 인앱결제
|
|
1907
|
+
* @name IAP
|
|
1908
|
+
* @description 인앱결제 관련 기능을 모은 객체예요. 단건 인앱결제 주문서 이동과 상품 목록 조회 기능을 제공해요.
|
|
1909
|
+
* @property {typeof createOneTimePurchaseOrder} [createOneTimePurchaseOrder] 특정 인앱결제 주문서 페이지로 이동해요. 자세한 내용은 [createOneTimePurchaseOrder](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 문서를 참고하세요.
|
|
1910
|
+
* @property {typeof getProductItemList} [getProductItemList] 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 자세한 내용은 [getProductItemList](/bedrock/reference/framework/인앱결제/getProductItemList.html) 문서를 참고하세요.
|
|
1911
|
+
*/
|
|
1912
|
+
declare const IAP: {
|
|
1913
|
+
createOneTimePurchaseOrder: typeof createOneTimePurchaseOrder;
|
|
1914
|
+
getProductItemList: typeof getProductItemList;
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1719
1917
|
/**
|
|
1720
1918
|
* @public
|
|
1721
1919
|
* @category 토스페이
|
|
@@ -1859,7 +2057,26 @@ declare class AppBridgeCallbackEvent extends BedrockEventDefinition<void, AppBri
|
|
|
1859
2057
|
private ensureInvokeAppBridgeCallback;
|
|
1860
2058
|
}
|
|
1861
2059
|
|
|
1862
|
-
|
|
2060
|
+
interface VisibilityChangedByTransparentServiceWebOptions {
|
|
2061
|
+
callbackId: string;
|
|
2062
|
+
}
|
|
2063
|
+
declare class VisibilityChangedByTransparentServiceWebEvent extends BedrockEventDefinition<VisibilityChangedByTransparentServiceWebOptions, boolean> {
|
|
2064
|
+
name: "onVisibilityChangedByTransparentServiceWeb";
|
|
2065
|
+
subscription: EmitterSubscription | null;
|
|
2066
|
+
remove(): void;
|
|
2067
|
+
listener(options: VisibilityChangedByTransparentServiceWebOptions, onEvent: (isVisible: boolean) => void, onError: (error: unknown) => void): void;
|
|
2068
|
+
private isVisibilityChangedByTransparentServiceWebResult;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
declare const appsInTossEvent: BedrockEvent<EntryMessageExitedEvent | VisibilityChangedByTransparentServiceWebEvent | UpdateLocationEvent | AppBridgeCallbackEvent>;
|
|
2072
|
+
|
|
2073
|
+
declare function onVisibilityChangedByTransparentServiceWeb(eventParams: {
|
|
2074
|
+
options: VisibilityChangedByTransparentServiceWebOptions;
|
|
2075
|
+
onEvent: (isVisible: boolean) => void;
|
|
2076
|
+
onError: (error: unknown) => void;
|
|
2077
|
+
}): () => void;
|
|
2078
|
+
|
|
2079
|
+
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
|
1863
2080
|
|
|
1864
2081
|
declare const Analytics: {
|
|
1865
2082
|
init: (options: _apps_in_toss_analytics.AnalyticsConfig) => void;
|
|
@@ -1868,4 +2085,4 @@ declare const Analytics: {
|
|
|
1868
2085
|
Area: ({ children, params: _params, ...props }: _apps_in_toss_analytics.LoggingAreaProps) => react_jsx_runtime.JSX.Element;
|
|
1869
2086
|
};
|
|
1870
2087
|
|
|
1871
|
-
export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, setClipboardText, setDeviceOrientation, startUpdateLocation, useGeolocation };
|
|
2088
|
+
export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, IAP, INTERNAL__onVisibilityChangedByTransparentServiceWeb, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type SaveBase64DataParams, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, saveBase64Data, setClipboardText, setDeviceOrientation, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1716,6 +1716,204 @@ declare function setDeviceOrientation(options: {
|
|
|
1716
1716
|
type: 'portrait' | 'landscape';
|
|
1717
1717
|
}): Promise<void>;
|
|
1718
1718
|
|
|
1719
|
+
interface SaveBase64DataParams {
|
|
1720
|
+
data: string;
|
|
1721
|
+
fileName: string;
|
|
1722
|
+
mimeType: string;
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* @public
|
|
1726
|
+
* @category 데이터
|
|
1727
|
+
* @name saveBase64Data
|
|
1728
|
+
* @description 문자열로 인코딩된 Base64 데이터를 지정한 파일 이름과 MIME 타입으로 사용자 기기에 저장해요. 이미지, 텍스트, PDF 등 다양한 형식의 데이터를 저장할 수 있어요.
|
|
1729
|
+
* @param {SaveBase64DataParams} params - 저장할 데이터와 파일 정보를 담은 객체예요.
|
|
1730
|
+
* @param {string} params.data - Base64 형식으로 인코딩된 데이터 문자열이에요.
|
|
1731
|
+
* @param {string} params.fileName - 저장할 파일 이름이에요. 확장자도 같이 붙여줘야해요. 예를 들어, 'example.png'로 저장할 수 있어요.
|
|
1732
|
+
* @param {string} params.mimeType - 저장할 파일의 MIME 타입이에요. 예를 들어 'image/png' 로 지정하면 이미지, 'application/pdf'는 PDF 파일이에요. 자세한 내용은 [MIME 문서](https://developer.mozilla.org/ko/docs/Web/HTTP/Guides/MIME_types)를 참고해주세요.
|
|
1733
|
+
*
|
|
1734
|
+
* @example
|
|
1735
|
+
* ### Base64 이미지 데이터를 사용자 기기에 저장하기
|
|
1736
|
+
*
|
|
1737
|
+
* ```tsx
|
|
1738
|
+
* import { Button } from 'react-native';
|
|
1739
|
+
* import { saveBase64Data } from '@apps-in-toss/framework';
|
|
1740
|
+
*
|
|
1741
|
+
* // '저장' 버튼을 누르면 이미지가 사용자 기기에 저장돼요.
|
|
1742
|
+
* function SaveButton() {
|
|
1743
|
+
* const handleSave = async () => {
|
|
1744
|
+
* try {
|
|
1745
|
+
* await saveBase64Data({
|
|
1746
|
+
* data: 'iVBORw0KGgo...',
|
|
1747
|
+
* fileName: 'some-photo.png',
|
|
1748
|
+
* mimeType: 'image/png',
|
|
1749
|
+
* });
|
|
1750
|
+
* } catch (error) {
|
|
1751
|
+
* console.error('데이터 저장에 실패했어요:', error);
|
|
1752
|
+
* }
|
|
1753
|
+
* };
|
|
1754
|
+
*
|
|
1755
|
+
* return <Button title="저장" onPress={handleSave} />;
|
|
1756
|
+
* }
|
|
1757
|
+
* ```
|
|
1758
|
+
*/
|
|
1759
|
+
declare function saveBase64Data(params: SaveBase64DataParams): Promise<void>;
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* @public
|
|
1763
|
+
* @category 인앱결제
|
|
1764
|
+
* @name IapCreateOneTimePurchaseOrderOptions
|
|
1765
|
+
* @description 인앱결제 1건을 요청할 때 필요한 정보예요.
|
|
1766
|
+
* @property {string} productId - 주문할 상품의 ID예요.
|
|
1767
|
+
*/
|
|
1768
|
+
interface IapCreateOneTimePurchaseOrderOptions {
|
|
1769
|
+
productId: string;
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* @public
|
|
1773
|
+
* @category 인앱결제
|
|
1774
|
+
* @name IapCreateOneTimePurchaseOrderResult
|
|
1775
|
+
* @description 인앱결제 1건이 완료되면 결제 세부 정보와 상품 정보를 담아 반환해요. 반환된 정보로 결제한 상품의 정보를 화면에 표시할 수 있어요.
|
|
1776
|
+
* @property {string | null} miniAppIconUrl - 미니앱 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요. 콘솔에서 아이콘을 등록하지 않았다면 `null`로 반환돼요.
|
|
1777
|
+
* @property {string} displayName - 화면에 표시할 상품 이름이에요.
|
|
1778
|
+
* @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
|
|
1779
|
+
* @property {number} amount - 상품 가격 숫자 값이에요. 화폐 단위와 쉼표를 제외한 순수 숫자예요. 예를 들어 `1000`으로 표시돼요.
|
|
1780
|
+
* @property {string} currency - [ISO 4217 표준](https://ko.wikipedia.org/wiki/ISO_4217)에 따른 상품 가격 통화 단위예요. 예를 들어 원화는 `KRW`, 달러는 `USD`로 표시돼요.
|
|
1781
|
+
* @property {number} fraction - 가격을 표시할 때 소수점 아래 몇 자리까지 보여줄지 정하는 값이에요. 예를 들어 달러는 소수점 둘째 자리까지 보여줘서 `2`, 원화는 소수점이 필요 없어서 `0`이에요
|
|
1782
|
+
*/
|
|
1783
|
+
interface IapCreateOneTimePurchaseOrderResult {
|
|
1784
|
+
miniAppIconUrl: string | null;
|
|
1785
|
+
displayName: string;
|
|
1786
|
+
displayAmount: string;
|
|
1787
|
+
amount: number;
|
|
1788
|
+
currency: string;
|
|
1789
|
+
fraction: number;
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* @public
|
|
1793
|
+
* @category 인앱결제
|
|
1794
|
+
* @name iapCreateOneTimePurchaseOrder
|
|
1795
|
+
* @description
|
|
1796
|
+
* 특정 인앱결제 주문서 페이지로 이동해요. 사용자가 상품 구매 버튼을 누르는 상황 등에 사용할 수 있어요. 사용자의 결제는 이동한 페이지에서 진행돼요. 만약 결제 중에 에러가 발생하면 에러 유형에 따라 에러 페이지로 이동해요.
|
|
1797
|
+
* @param {IapCreateOneTimePurchaseOrderOptions} params - 인앱결제를 생성할 때 필요한 정보예요.
|
|
1798
|
+
* @param {string} params.productId - 주문할 상품의 ID예요.
|
|
1799
|
+
* @returns {Promise<IapCreateOneTimePurchaseOrderResult | undefined>} 결제에 성공하면 결제 결과 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 인앱결제를 실행할 수 없어서 `undefined`를 반환해요.
|
|
1800
|
+
*
|
|
1801
|
+
* @throw {code: "INVALID_PRODUCT_ID"} - 유효하지 않은 상품 ID이거나, 해당 상품이 존재하지 않을 때 발생해요.
|
|
1802
|
+
* @throw {code: "PAYMENT_PENDING"} - 사용자가 요청한 결제가 아직 승인을 기다리고 있을 때 발생해요.
|
|
1803
|
+
* @throw {code: "NETWORK_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
|
|
1804
|
+
* @throw {code: "INVALID_USER_ENVIRONMENT"} - 특정 기기, 계정 또는 설정 환경에서 구매할 수 없는 상품일 때 발생해요.
|
|
1805
|
+
* @throw {code: "ITEM_ALREADY_OWNED"} - 사용자가 이미 구매한 상품을 다시 구매하려고 할 때 발생해요.
|
|
1806
|
+
* @throw {code: "APP_MARKET_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 앱스토어에서 사용자 정보 검증에 실패했을 때 발생해요. 사용자가 앱스토어에 문의해서 환불을 요청해야해요.
|
|
1807
|
+
* @throw {code: "TOSS_SERVER_VERIFICATION_FAILED"} - 사용자가 결제를 완료했지만, 서버 전송에 실패해서 결제 정보를 저장할 수 없을 때 발생해요.
|
|
1808
|
+
* @throw {code: "INTERNAL_ERROR"} - 서버 내부 문제로 요청을 처리할 수 없을 때 발생해요.
|
|
1809
|
+
* @throw {code: "KOREAN_ACCOUNT_ONLY"} - iOS 환경에서 사용자의 계정이 한국 계정이 아닐 때 발생해요.
|
|
1810
|
+
* @throw {code: "USER_CANCELED"} - 사용자가 결제를 완료하지 않고 주문서 페이지를 이탈했을 때 발생해요.
|
|
1811
|
+
*
|
|
1812
|
+
* @example
|
|
1813
|
+
* ### 특정 인앱결제 주문서 페이지로 이동하기
|
|
1814
|
+
*
|
|
1815
|
+
* ```tsx
|
|
1816
|
+
* import { Button } from 'react-native';
|
|
1817
|
+
* import { IAP } from '@apps-in-toss/framework';
|
|
1818
|
+
*
|
|
1819
|
+
* interface Props {
|
|
1820
|
+
* productId: string;
|
|
1821
|
+
* }
|
|
1822
|
+
*
|
|
1823
|
+
* function IapCreateOneTimePurchaseOrderButton({ productId }: Props) {
|
|
1824
|
+
* const handleClick = async () => {
|
|
1825
|
+
* try {
|
|
1826
|
+
* await IAP.createOneTimePurchaseOrder({
|
|
1827
|
+
* productId,
|
|
1828
|
+
* });
|
|
1829
|
+
* } catch (error) {
|
|
1830
|
+
* console.error('인앱결제에 실패했어요:', error);
|
|
1831
|
+
* }
|
|
1832
|
+
* };
|
|
1833
|
+
*
|
|
1834
|
+
* return <Button title="구매하기" onPress={handleClick} />;
|
|
1835
|
+
* }
|
|
1836
|
+
* ```
|
|
1837
|
+
*/
|
|
1838
|
+
declare function createOneTimePurchaseOrder(params: IapCreateOneTimePurchaseOrderOptions): Promise<IapCreateOneTimePurchaseOrderResult | undefined>;
|
|
1839
|
+
/**
|
|
1840
|
+
* @public
|
|
1841
|
+
* @category 인앱결제
|
|
1842
|
+
* @name IapProductListItem
|
|
1843
|
+
* @description 인앱결제로 구매할 수 있는 상품 하나의 정보를 담은 객체예요. 상품 목록을 화면에 표시할 때 사용해요.
|
|
1844
|
+
* @property {string} sku - 상품의 고유 ID예요. [인앱결제 주문서 페이지로 이동할때](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 사용하는 `productId`와 동일한 값이에요.
|
|
1845
|
+
* @property {string} displayName - 화면에 표시할 상품 이름이에요. 상품 이름은 앱인토스 콘솔에서 설정한 값이에요.
|
|
1846
|
+
* @property {string} displayAmount - 통화 단위가 포함된 가격 정보예요. 예를 들어 `1,000원`으로 가격과 통화가 함께 표시돼요.
|
|
1847
|
+
* @property {string} iconUrl - 상품 아이콘 이미지의 URL이에요. 아이콘은 앱인토스 콘솔에서 설정한 이미지예요.
|
|
1848
|
+
* @property {string} description - 상품에 대한 설명이에요. 설명은 앱인토스 콘솔에서 설정한 값이에요.
|
|
1849
|
+
*/
|
|
1850
|
+
interface IapProductListItem {
|
|
1851
|
+
sku: string;
|
|
1852
|
+
displayAmount: string;
|
|
1853
|
+
displayName: string;
|
|
1854
|
+
iconUrl: string;
|
|
1855
|
+
description: string;
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* @public
|
|
1859
|
+
* @category 인앱결제
|
|
1860
|
+
* @name iapGetProductItemList
|
|
1861
|
+
* @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요.
|
|
1862
|
+
* @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요.
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ### 구매 가능한 인앱결제 상품목록 가져오기
|
|
1866
|
+
*
|
|
1867
|
+
* ```tsx
|
|
1868
|
+
* import { useEffect, useState } from 'react';
|
|
1869
|
+
* import { List, ListRow, Txt } from '@toss-design-system/react-native';
|
|
1870
|
+
* import { IAP } from '@apps-in-toss/framework';
|
|
1871
|
+
*
|
|
1872
|
+
* function IapGetProductItemList() {
|
|
1873
|
+
* const [products, setProducts] = useState<IapProductListItem[]>([]);
|
|
1874
|
+
*
|
|
1875
|
+
* useEffect(() => {
|
|
1876
|
+
* async function fetchProducts() {
|
|
1877
|
+
* try {
|
|
1878
|
+
* const response = await IAP.getProductItemList();
|
|
1879
|
+
* setProducts(response?.products ?? []);
|
|
1880
|
+
* } catch (error) {
|
|
1881
|
+
* console.error('상품 목록을 가져오는 데 실패했어요:', error);
|
|
1882
|
+
* }
|
|
1883
|
+
* }
|
|
1884
|
+
*
|
|
1885
|
+
* fetchProducts();
|
|
1886
|
+
* }, []);
|
|
1887
|
+
*
|
|
1888
|
+
* return (
|
|
1889
|
+
* <List>
|
|
1890
|
+
* {products.map((product) => (
|
|
1891
|
+
* <ListRow
|
|
1892
|
+
* key={product.sku}
|
|
1893
|
+
* contents={<Txt>{product.displayName}</Txt>}
|
|
1894
|
+
* />
|
|
1895
|
+
* ))}
|
|
1896
|
+
* </List>
|
|
1897
|
+
* );
|
|
1898
|
+
* }
|
|
1899
|
+
* ```
|
|
1900
|
+
*/
|
|
1901
|
+
declare function getProductItemList(): Promise<{
|
|
1902
|
+
products: IapProductListItem[];
|
|
1903
|
+
} | undefined>;
|
|
1904
|
+
/**
|
|
1905
|
+
* @public
|
|
1906
|
+
* @category 인앱결제
|
|
1907
|
+
* @name IAP
|
|
1908
|
+
* @description 인앱결제 관련 기능을 모은 객체예요. 단건 인앱결제 주문서 이동과 상품 목록 조회 기능을 제공해요.
|
|
1909
|
+
* @property {typeof createOneTimePurchaseOrder} [createOneTimePurchaseOrder] 특정 인앱결제 주문서 페이지로 이동해요. 자세한 내용은 [createOneTimePurchaseOrder](/bedrock/reference/framework/인앱결제/createOneTimePurchaseOrder.html) 문서를 참고하세요.
|
|
1910
|
+
* @property {typeof getProductItemList} [getProductItemList] 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 자세한 내용은 [getProductItemList](/bedrock/reference/framework/인앱결제/getProductItemList.html) 문서를 참고하세요.
|
|
1911
|
+
*/
|
|
1912
|
+
declare const IAP: {
|
|
1913
|
+
createOneTimePurchaseOrder: typeof createOneTimePurchaseOrder;
|
|
1914
|
+
getProductItemList: typeof getProductItemList;
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1719
1917
|
/**
|
|
1720
1918
|
* @public
|
|
1721
1919
|
* @category 토스페이
|
|
@@ -1859,7 +2057,26 @@ declare class AppBridgeCallbackEvent extends BedrockEventDefinition<void, AppBri
|
|
|
1859
2057
|
private ensureInvokeAppBridgeCallback;
|
|
1860
2058
|
}
|
|
1861
2059
|
|
|
1862
|
-
|
|
2060
|
+
interface VisibilityChangedByTransparentServiceWebOptions {
|
|
2061
|
+
callbackId: string;
|
|
2062
|
+
}
|
|
2063
|
+
declare class VisibilityChangedByTransparentServiceWebEvent extends BedrockEventDefinition<VisibilityChangedByTransparentServiceWebOptions, boolean> {
|
|
2064
|
+
name: "onVisibilityChangedByTransparentServiceWeb";
|
|
2065
|
+
subscription: EmitterSubscription | null;
|
|
2066
|
+
remove(): void;
|
|
2067
|
+
listener(options: VisibilityChangedByTransparentServiceWebOptions, onEvent: (isVisible: boolean) => void, onError: (error: unknown) => void): void;
|
|
2068
|
+
private isVisibilityChangedByTransparentServiceWebResult;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
declare const appsInTossEvent: BedrockEvent<EntryMessageExitedEvent | VisibilityChangedByTransparentServiceWebEvent | UpdateLocationEvent | AppBridgeCallbackEvent>;
|
|
2072
|
+
|
|
2073
|
+
declare function onVisibilityChangedByTransparentServiceWeb(eventParams: {
|
|
2074
|
+
options: VisibilityChangedByTransparentServiceWebOptions;
|
|
2075
|
+
onEvent: (isVisible: boolean) => void;
|
|
2076
|
+
onError: (error: unknown) => void;
|
|
2077
|
+
}): () => void;
|
|
2078
|
+
|
|
2079
|
+
declare const INTERNAL__onVisibilityChangedByTransparentServiceWeb: typeof onVisibilityChangedByTransparentServiceWeb;
|
|
1863
2080
|
|
|
1864
2081
|
declare const Analytics: {
|
|
1865
2082
|
init: (options: _apps_in_toss_analytics.AnalyticsConfig) => void;
|
|
@@ -1868,4 +2085,4 @@ declare const Analytics: {
|
|
|
1868
2085
|
Area: ({ children, params: _params, ...props }: _apps_in_toss_analytics.LoggingAreaProps) => react_jsx_runtime.JSX.Element;
|
|
1869
2086
|
};
|
|
1870
2087
|
|
|
1871
|
-
export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, setClipboardText, setDeviceOrientation, startUpdateLocation, useGeolocation };
|
|
2088
|
+
export { Accuracy, Analytics, AppsInToss, type ContactEntity, type EventLogParams, type ExternalWebViewProps, type FetchAlbumPhotosOptions, type GameWebViewProps, type GetCurrentLocationOptions, GoogleAdMob, IAP, INTERNAL__onVisibilityChangedByTransparentServiceWeb, type IapCreateOneTimePurchaseOrderOptions, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, type ImageResponse, type LoadAdMobInterstitialAdEvent, type LoadAdMobInterstitialAdOptions, type LoadAdMobRewardedAdEvent, type LoadAdMobRewardedAdOptions, type Location, type LocationCoords, type OpenCameraOptions, type PartnerWebViewProps, type SaveBase64DataParams, type ShowAdMobInterstitialAdEvent, type ShowAdMobInterstitialAdOptions, type ShowAdMobRewardedAdEvent, type ShowAdMobRewardedAdOptions, type StartUpdateLocationOptions$1 as StartUpdateLocationOptions, type StartUpdateLocationSubscription, Storage, TossPay, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, appLogin, appsInTossEvent, env, eventLog, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, getDeviceId, getOperationalEnvironment, getTossAppVersion, getTossShareLink, isMinVersionSupported, openCamera, saveBase64Data, setClipboardText, setDeviceOrientation, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -367,11 +367,39 @@ var AppBridgeCallbackEvent = class _AppBridgeCallbackEvent extends BedrockEventD
|
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
+
// src/native-event-emitter/internal/VisibilityChangedByTransparentServiceWebEvent.ts
|
|
371
|
+
import { BedrockEventDefinition as BedrockEventDefinition4 } from "react-native-bedrock";
|
|
372
|
+
var VisibilityChangedByTransparentServiceWebEvent = class extends BedrockEventDefinition4 {
|
|
373
|
+
name = "onVisibilityChangedByTransparentServiceWeb";
|
|
374
|
+
subscription = null;
|
|
375
|
+
remove() {
|
|
376
|
+
this.subscription?.remove();
|
|
377
|
+
this.subscription = null;
|
|
378
|
+
}
|
|
379
|
+
listener(options, onEvent, onError) {
|
|
380
|
+
const subscription = nativeEventEmitter.addListener("visibilityChangedByTransparentServiceWeb", (params) => {
|
|
381
|
+
if (this.isVisibilityChangedByTransparentServiceWebResult(params)) {
|
|
382
|
+
if (params.callbackId === options.callbackId) {
|
|
383
|
+
onEvent(params.isVisible);
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
onError(new Error("Invalid visibility changed by transparent service web result"));
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
this.subscription = subscription;
|
|
390
|
+
}
|
|
391
|
+
isVisibilityChangedByTransparentServiceWebResult(params) {
|
|
392
|
+
return typeof params === "object" && typeof params.callbackId === "string" && typeof params.isVisible === "boolean";
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
|
|
370
396
|
// src/native-event-emitter/appsInTossEvent.ts
|
|
371
397
|
var appsInTossEvent = new BedrockEvent([
|
|
372
|
-
new AppBridgeCallbackEvent(),
|
|
373
398
|
new UpdateLocationEvent(),
|
|
374
|
-
new EntryMessageExitedEvent()
|
|
399
|
+
new EntryMessageExitedEvent(),
|
|
400
|
+
// Internal events
|
|
401
|
+
new AppBridgeCallbackEvent(),
|
|
402
|
+
new VisibilityChangedByTransparentServiceWebEvent()
|
|
375
403
|
]);
|
|
376
404
|
|
|
377
405
|
// src/core/utils/getAppsInTossGlobals.ts
|
|
@@ -419,6 +447,7 @@ __export(async_bridges_exports, {
|
|
|
419
447
|
getCurrentLocation: () => getCurrentLocation,
|
|
420
448
|
getTossShareLink: () => getTossShareLink,
|
|
421
449
|
openCamera: () => openCamera,
|
|
450
|
+
saveBase64Data: () => saveBase64Data,
|
|
422
451
|
setClipboardText: () => setClipboardText,
|
|
423
452
|
setDeviceOrientation: () => setDeviceOrientation
|
|
424
453
|
});
|
|
@@ -559,6 +588,19 @@ async function setDeviceOrientation(options) {
|
|
|
559
588
|
return AppsInTossModule.setDeviceOrientation(options);
|
|
560
589
|
}
|
|
561
590
|
|
|
591
|
+
// src/native-modules/saveBase64Data.ts
|
|
592
|
+
async function saveBase64Data(params) {
|
|
593
|
+
const isSupported = isMinVersionSupported({
|
|
594
|
+
android: "5.218.0",
|
|
595
|
+
ios: "5.216.0"
|
|
596
|
+
});
|
|
597
|
+
if (!isSupported) {
|
|
598
|
+
console.warn("saveBase64Data is not supported in this app version");
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
await AppsInTossModule.saveBase64Data(params);
|
|
602
|
+
}
|
|
603
|
+
|
|
562
604
|
// src/core/registerApp.tsx
|
|
563
605
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
564
606
|
function AppsInTossContainer(Container, { children, ...initialProps }) {
|
|
@@ -700,7 +742,6 @@ var ENVIRONMENT = getOperationalEnvironment();
|
|
|
700
742
|
function createIsSupported() {
|
|
701
743
|
return () => {
|
|
702
744
|
if (ENVIRONMENT !== "toss") {
|
|
703
|
-
console.warn("Google AdMob is not supported in the current environment");
|
|
704
745
|
return false;
|
|
705
746
|
}
|
|
706
747
|
return isMinVersionSupported({
|
|
@@ -747,6 +788,32 @@ var Storage = {
|
|
|
747
788
|
clearItems
|
|
748
789
|
};
|
|
749
790
|
|
|
791
|
+
// src/native-modules/iap.ts
|
|
792
|
+
async function createOneTimePurchaseOrder(params) {
|
|
793
|
+
const isSupported = isMinVersionSupported({
|
|
794
|
+
android: "5.219.0",
|
|
795
|
+
ios: "5.219.0"
|
|
796
|
+
});
|
|
797
|
+
if (!isSupported) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
return AppsInTossModule.iapCreateOneTimePurchaseOrder(params);
|
|
801
|
+
}
|
|
802
|
+
async function getProductItemList() {
|
|
803
|
+
const isSupported = isMinVersionSupported({
|
|
804
|
+
android: "5.219.0",
|
|
805
|
+
ios: "5.219.0"
|
|
806
|
+
});
|
|
807
|
+
if (!isSupported) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
return AppsInTossModule.iapGetProductItemList({});
|
|
811
|
+
}
|
|
812
|
+
var IAP = {
|
|
813
|
+
createOneTimePurchaseOrder,
|
|
814
|
+
getProductItemList
|
|
815
|
+
};
|
|
816
|
+
|
|
750
817
|
// src/native-modules/index.ts
|
|
751
818
|
var TossPay = {
|
|
752
819
|
checkoutPayment
|
|
@@ -1183,7 +1250,10 @@ function WebView({ type, local, onMessage, ...props }) {
|
|
|
1183
1250
|
getStorageItem: Storage.getItem,
|
|
1184
1251
|
setStorageItem: Storage.setItem,
|
|
1185
1252
|
removeStorageItem: Storage.removeItem,
|
|
1186
|
-
clearItems: Storage.clearItems
|
|
1253
|
+
clearItems: Storage.clearItems,
|
|
1254
|
+
/** IAP */
|
|
1255
|
+
iapCreateOneTimePurchaseOrder: IAP.createOneTimePurchaseOrder,
|
|
1256
|
+
iapGetProductItemList: IAP.getProductItemList
|
|
1187
1257
|
}
|
|
1188
1258
|
});
|
|
1189
1259
|
const baseProps = useMemo3(() => {
|
|
@@ -1280,6 +1350,14 @@ var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
|
1280
1350
|
return Accuracy3;
|
|
1281
1351
|
})(Accuracy2 || {});
|
|
1282
1352
|
|
|
1353
|
+
// src/native-event-emitter/internal/onVisibilityChangedByTransparentServiceWeb.ts
|
|
1354
|
+
function onVisibilityChangedByTransparentServiceWeb(eventParams) {
|
|
1355
|
+
return appsInTossEvent.addEventListener("onVisibilityChangedByTransparentServiceWeb", eventParams);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
// src/private.ts
|
|
1359
|
+
var INTERNAL__onVisibilityChangedByTransparentServiceWeb = onVisibilityChangedByTransparentServiceWeb;
|
|
1360
|
+
|
|
1283
1361
|
// src/index.ts
|
|
1284
1362
|
export * from "@apps-in-toss/analytics";
|
|
1285
1363
|
var Analytics2 = {
|
|
@@ -1293,6 +1371,8 @@ export {
|
|
|
1293
1371
|
Analytics2 as Analytics,
|
|
1294
1372
|
AppsInToss,
|
|
1295
1373
|
GoogleAdMob,
|
|
1374
|
+
IAP,
|
|
1375
|
+
INTERNAL__onVisibilityChangedByTransparentServiceWeb,
|
|
1296
1376
|
Storage,
|
|
1297
1377
|
TossPay,
|
|
1298
1378
|
WebView,
|
|
@@ -1310,6 +1390,7 @@ export {
|
|
|
1310
1390
|
getTossShareLink,
|
|
1311
1391
|
isMinVersionSupported,
|
|
1312
1392
|
openCamera,
|
|
1393
|
+
saveBase64Data,
|
|
1313
1394
|
setClipboardText,
|
|
1314
1395
|
setDeviceOrientation,
|
|
1315
1396
|
startUpdateLocation,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.29",
|
|
5
5
|
"description": "The framework for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"ait": "./bin/ait.js"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@apps-in-toss/analytics": "0.0.
|
|
61
|
-
"@apps-in-toss/cli": "0.0.
|
|
62
|
-
"@apps-in-toss/plugins": "0.0.
|
|
60
|
+
"@apps-in-toss/analytics": "0.0.29",
|
|
61
|
+
"@apps-in-toss/cli": "0.0.29",
|
|
62
|
+
"@apps-in-toss/plugins": "0.0.29",
|
|
63
63
|
"es-hangul": "^2.3.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "d05ff237b358da05d562728d0ac965f00c419d63"
|
|
97
97
|
}
|
package/src/async-bridges.ts
CHANGED