@apps-in-toss/web-bridge 0.0.24

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @apps-in-toss/web-bridge
2
+
3
+ Analytics for Apps In Toss
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @public
3
+ * @category 로그인
4
+ * @name appLogin
5
+ * @description 토스 인증으로 로그인해요. 로그인이 완료되면 다시 토스 앱으로 이동해요.
6
+ * @example
7
+ *
8
+ * ### 토스 인증을 통해 로그인을 하는 예제
9
+ *
10
+ * ```tsx
11
+ *
12
+ * import { appLogin } from '@apps-in-toss/web-framework';
13
+ *
14
+ * function Page() {
15
+ * const handleLogin = async () => {
16
+ * const { authorizationCode, referrer } = await appLogin();
17
+ *
18
+ * // 획득한 인가 코드(`authorizationCode`)와 `referrer`를 서버로 전달해요.
19
+ * }
20
+ *
21
+ * return <input type="button" value="로그인" onClick={handleLogin} />;
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function appLogin(): Promise<{
26
+ authorizationCode: string;
27
+ referrer: "DEFAULT" | "SANDBOX";
28
+ }>;
29
+
30
+ export {};
@@ -0,0 +1,25 @@
1
+ export * from './closeView';
2
+ export * from './generateHapticFeedback';
3
+ export * from './share';
4
+ export * from './setSecureScreen';
5
+ export * from './setScreenAwakeMode';
6
+ export * from './getNetworkStatus';
7
+ export * from './setIosSwipeGestureEnabled';
8
+ export * from './openURL';
9
+ export * from './getLocale';
10
+ export * from './getSchemeUri';
11
+ export * from './getPlatformOS';
12
+ export * from './setClipboardText';
13
+ export * from './getClipboardText';
14
+ export * from './fetchContacts';
15
+ export * from './fetchAlbumPhotos';
16
+ export * from './getCurrentLocation';
17
+ export * from './openCamera';
18
+ export * from './appLogin';
19
+ export * from './checkoutPayment';
20
+ export * from './eventLog';
21
+ export * from './getTossShareLink';
22
+ export * from './getOperationalEnvironment';
23
+ export * from './getTossAppVersion';
24
+ export * from './getDeviceId';
25
+ export * from './startUpdateLocation';
@@ -0,0 +1 @@
1
+ import{createAsyncBridge,createConstantBridge,createEventBridge}from"@apps-in-toss/bridge-core";var createEvents=function(){return{emit:function emit(event,args){for(var callbacks=this.events[event]||[],i=0,length=callbacks.length;i<length;i++){callbacks[i](args)}},events:{},on:function on(event,cb){var _this=this;var _this_events,_event;((_this_events=this.events)[_event=event]||(_this_events[_event]=[])).push(cb);return function(){var _this_events_event;_this.events[event]=(_this_events_event=_this.events[event])===null||_this_events_event===void 0?void 0:_this_events_event.filter(function(i){return cb!==i})}}}};if(typeof window!=="undefined"){window.__BEDROCK_NATIVE_EMITTER=createEvents()}export var closeView=createAsyncBridge("closeView");export var generateHapticFeedback=createAsyncBridge("generateHapticFeedback");export var share=createAsyncBridge("share");export var setSecureScreen=createAsyncBridge("setSecureScreen");export var setScreenAwakeMode=createAsyncBridge("setScreenAwakeMode");export var getNetworkStatus=createAsyncBridge("getNetworkStatus");export var setIosSwipeGestureEnabled=createAsyncBridge("setIosSwipeGestureEnabled");export var openURL=createAsyncBridge("openURL");export var getLocale=createConstantBridge("getLocale");export var getSchemeUri=createConstantBridge("getSchemeUri");export var getPlatformOS=createConstantBridge("getPlatformOS");export var setClipboardText=createAsyncBridge("setClipboardText");export var getClipboardText=createAsyncBridge("getClipboardText");export var fetchContacts=createAsyncBridge("fetchContacts");export var fetchAlbumPhotos=createAsyncBridge("fetchAlbumPhotos");export var Accuracy=function(Accuracy){Accuracy[Accuracy["Lowest"]=1]="Lowest";Accuracy[Accuracy["Low"]=2]="Low";Accuracy[Accuracy["Balanced"]=3]="Balanced";Accuracy[Accuracy["High"]=4]="High";Accuracy[Accuracy["Highest"]=5]="Highest";Accuracy[Accuracy["BestForNavigation"]=6]="BestForNavigation";return Accuracy}({});export var getCurrentLocation=createAsyncBridge("getCurrentLocation");export var openCamera=createAsyncBridge("openCamera");export var appLogin=createAsyncBridge("appLogin");export var checkoutPayment=createAsyncBridge("checkoutPayment");export var eventLog=createAsyncBridge("eventLog");export var getTossShareLink=createAsyncBridge("getTossShareLink");export var getOperationalEnvironment=createConstantBridge("getOperationalEnvironment");export var getTossAppVersion=createConstantBridge("getTossAppVersion");export var getDeviceId=createConstantBridge("getDeviceId");export var startUpdateLocation=createEventBridge("startUpdateLocation");
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @public
3
+ * @category 토스페이
4
+ * @name CheckoutPaymentOptions
5
+ * @description 토스페이 결제창을 띄울 때 필요한 옵션이에요.
6
+ * @property {string} payToken 결제 토큰이에요.
7
+ */
8
+ export interface CheckoutPaymentOptions {
9
+ /**
10
+ * 결제 토큰이에요.
11
+ */
12
+ payToken: string;
13
+ }
14
+ /**
15
+ * @public
16
+ * @category 토스페이
17
+ * @name CheckoutPaymentResult
18
+ * @description 토스페이 결제창에서 사용자가 인증에 성공했는지 여부예요.
19
+ * @property {boolean} success 인증이 성공했는지 여부예요.
20
+ * @property {string} [reason] 인증이 실패했을 경우의 이유예요.
21
+ */
22
+ export interface CheckoutPaymentResult {
23
+ /**
24
+ * 인증이 성공했는지 여부예요.
25
+ */
26
+ success: boolean;
27
+ /**
28
+ * 인증이 실패했을 경우의 이유예요.
29
+ */
30
+ reason?: string;
31
+ }
32
+ /**
33
+ * @public
34
+ * @category 토스페이
35
+ * @name checkoutPayment
36
+ * @description 토스페이 결제창을 띄우고, 사용자 인증을 수행해요. 인증이 완료되면 성공 여부를 반환해요.
37
+ *
38
+ * 이 함수는 결제창을 통해 사용자 인증만 해요. 실제 결제 처리는 인증 성공 후 서버에서 별도로 해야 해요.
39
+ *
40
+ * @param {CheckoutPaymentOptions} options 결제창을 띄울 때 필요한 옵션이에요.
41
+ * @returns {Promise<CheckoutPaymentResult>} 인증 성공 여부를 포함한 결과를 반환해요.
42
+ *
43
+ * @example
44
+ *
45
+ * ### 토스페이 결제창 띄우고 인증 처리하기
46
+ *
47
+ * ```tsx
48
+ * import { TossPay } from '@apps-in-toss/web-framework';
49
+ *
50
+ * async function handlePayment() {
51
+ * try {
52
+ * // 실제 구현 시 결제 생성 역할을 하는 API 엔드포인트로 대체해주세요.
53
+ * const { payToken } = await fetch('/my-api/payment/create').then(res => res.json());
54
+ *
55
+ * const { success, reason } = await TossPay.checkoutPayment({ payToken });
56
+ *
57
+ * if (success) {
58
+ * // 실제 구현 시 결제를 실행하는 API 엔드포인트로 대체해주세요.
59
+ * await fetch('/my-api/payment/execute', {
60
+ * method: 'POST',
61
+ * body: JSON.stringify({ payToken }),
62
+ * headers: { 'Content-Type': 'application/json' },
63
+ * });
64
+ * } else {
65
+ * console.log('인증 실패:', reason);
66
+ * }
67
+ * } catch (error) {
68
+ * console.error('결제 인증 중 오류가 발생했어요:', error);
69
+ * }
70
+ * }
71
+ * ```
72
+ */
73
+ export declare function checkoutPayment(options: CheckoutPaymentOptions): Promise<CheckoutPaymentResult>;
74
+
75
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @public
3
+ * @category 화면 제어
4
+ * @kind function
5
+ * @name closeView
6
+ * @description 현재 화면을 닫는 함수에요. 예를 들어, "닫기" 버튼을 눌러서 서비스를 종료할 때 사용할 수 있어요.
7
+ * @returns {Promise<void>}
8
+ *
9
+ * @example
10
+ * ### 닫기 버튼을 눌러 화면 닫기
11
+ *
12
+ * ```tsx
13
+ *
14
+ * import { closeView } from '@apps-in-toss/web-framework';
15
+ *
16
+ * function CloseButton() {
17
+ * return <input type="button" value="닫기" onClick={closeView} />;
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function closeView(): Promise<void>;
22
+
23
+ export {};
@@ -0,0 +1,44 @@
1
+ export type Primitive = string | number | boolean | null | undefined | symbol;
2
+ export interface EventLogParams {
3
+ log_name: string;
4
+ log_type: "debug" | "info" | "warn" | "error" | "screen" | "impression" | "click";
5
+ params: Record<string, Primitive>;
6
+ }
7
+ /**
8
+ * @category 로깅
9
+ * @kind function
10
+ * @name eventLog
11
+ * @description
12
+ * 이벤트 로그를 기록하는 함수예요.
13
+ *
14
+ * 이 함수는 앱 내에서 발생하는 다양한 이벤트를 로깅하는 데 사용돼요. 디버깅, 정보 제공, 경고, 오류 등 다양한 유형의 로그를 기록할 수 있어요. 샌드박스 환경에서는 콘솔에 로그가 출력되고, 실제 환경에서는 로그 시스템에 기록돼요.
15
+ *
16
+ * @param {Object} params 로그 기록에 필요한 매개변수 객체예요.
17
+ * @param {string} params.log_name 로그의 이름이에요.
18
+ * @param {'debug' | 'info' | 'warn' | 'error' | 'screen' | 'impression' | 'click'} params.log_type 로그의 유형이에요.
19
+ * @param {Record<string, Primitive>} params.params 로그에 포함할 추가 매개변수 객체예요.
20
+ *
21
+ * @returns {Promise<void>} 로그 기록이 완료되면 해결되는 Promise예요.
22
+ *
23
+ * @example
24
+ * ### 이벤트 로그 기록하기
25
+ *
26
+ * ```tsx
27
+ * import { eventLog } from '@apps-in-toss/web-framework';
28
+ *
29
+ * function logUserAction() {
30
+ * eventLog({
31
+ * log_name: 'user_action',
32
+ * log_type: 'info',
33
+ * params: {
34
+ * action: 'button_click',
35
+ * screen: 'main',
36
+ * userId: 12345
37
+ * }
38
+ * });
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function eventLog(params: EventLogParams): Promise<void>;
43
+
44
+ export {};
@@ -0,0 +1,78 @@
1
+ /**
2
+ * 사진 조회 결과를 나타내는 타입이에요.
3
+ */
4
+ export interface ImageResponse {
5
+ /** 가져온 사진의 고유 ID예요. */
6
+ id: string;
7
+ /** 사진의 데이터 URI예요. `base64` 옵션이 `true`인 경우 Base64 문자열로 반환돼요. */
8
+ dataUri: string;
9
+ }
10
+ /**
11
+ * 앨범 사진을 조회할 때 사용하는 옵션 타입이에요.
12
+ */
13
+ export interface FetchAlbumPhotosOptions {
14
+ /** 가져올 사진의 최대 개수를 설정해요. 숫자를 입력하고 기본값은 10이에요. */
15
+ maxCount?: number;
16
+ /** 사진의 최대 폭을 제한해요. 단위는 픽셀이고 기본값은 1024이에요. */
17
+ maxWidth?: number;
18
+ /** 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요. */
19
+ base64?: boolean;
20
+ }
21
+ /**
22
+ * @public
23
+ * @category 사진
24
+ * @name fetchAlbumPhotos
25
+ * @description
26
+ * 사용자의 앨범에서 사진 목록을 불러오는 함수예요.
27
+ * 최대 개수와 해상도를 설정할 수 있고 갤러리 미리보기, 이미지 선택 기능 등에 활용할 수 있어요.
28
+ *
29
+ * @param options - 조회 옵션을 담은 객체예요.
30
+ * @param {number} [options.maxCount=10] 가져올 사진의 최대 개수를 설정해요. 숫자로 입력하며 기본값은 10이에요.
31
+ * @param {number} [options.maxWidth=1024] 사진의 최대 폭을 제한해요. 단위는 픽셀이며 기본값은 `1024`이에요.
32
+ * @param {boolean} [options.base64=false] 이미지를 base64 형식으로 반환할지 설정해요. 기본값은 `false`예요.
33
+ * @returns {Promise<ImageResponse[]>}
34
+ * 앨범 사진의 고유 ID와 데이터 URI를 포함한 배열을 반환해요.
35
+ *
36
+ * @example
37
+ * ### 사진의 최대 폭을 360px로 제한하여 가져오기
38
+ *
39
+ * ```tsx
40
+ * import React, { useState } from 'react';
41
+ *
42
+ * import { fetchAlbumPhotos } from '@apps-in-toss/web-framework';
43
+ *
44
+ * const base64 = true;
45
+ *
46
+ * // 앨범 사진 목록을 가져와 화면에 표시하는 컴포넌트
47
+ * function AlbumPhotoList() {
48
+ * const [albumPhotos, setAlbumPhotos] = useState([]);
49
+ *
50
+ * const handlePress = async () => {
51
+ * try {
52
+ * const response = await fetchAlbumPhotos({
53
+ * base64,
54
+ * maxWidth: 360,
55
+ * });
56
+ * setAlbumPhotos((prev) => ([...prev, ...response]));
57
+ * } catch (error) {
58
+ * console.error('앨범을 가져오는 데 실패했어요:', error);
59
+ * }
60
+ * };
61
+ *
62
+ * return (
63
+ * <div>
64
+ * {albumPhotos.map((image) => {
65
+ * // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
66
+ * const imageUri = base64 ? 'data:image/jpeg;base64,' + image.dataUri : image.dataUri;
67
+ *
68
+ * return <Image source={{ uri: imageUri }} key={image.id} />;
69
+ * })}
70
+ * <input type="button" value="앨범 가져오기" onClick={handlePress} />
71
+ * </div>
72
+ * );
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function fetchAlbumPhotos(options: FetchAlbumPhotosOptions): Promise<ImageResponse[]>;
77
+
78
+ export {};
@@ -0,0 +1,109 @@
1
+ /**
2
+ * 연락처 정보를 나타내는 타입이에요.
3
+ */
4
+ export interface ContactEntity {
5
+ /** 연락처 이름이에요. */
6
+ name: string;
7
+ /** 연락처 전화번호로, 문자열 형식이에요. */
8
+ phoneNumber: string;
9
+ }
10
+ /**
11
+ * @public
12
+ * @category 연락처
13
+ * @name fetchContacts
14
+ * @description 사용자의 연락처 목록을 페이지 단위로 가져오는 함수예요.
15
+ * @param size - 한 번에 가져올 연락처 개수예요. 예를 들어, 10을 전달하면 최대 10개의 연락처를 가져와요.
16
+ * @param offset - 가져올 연락처의 시작 지점이에요. 처음 호출할 때는 `0`을 전달해야 해요. 이후에는 이전 호출에서 반환된 `nextOffset` 값을 사용해요.
17
+ * @param query - 추가적인 필터링 옵션이에요.
18
+ * @param query.contains - 이름에 특정 문자열이 포함된 연락처만 가져오고 싶을 때 사용해요. 이 값을 전달하지 않으면 모든 연락처를 가져와요.
19
+ * @returns {Promise<{result: { name: string; phoneNumber: string }[]; nextOffset: number | null; done: boolean}>}
20
+ * 연락처 목록과 페이지네이션 정보를 포함한 객체를 반환해요.
21
+ * - `result`: 가져온 연락처 목록이에요.
22
+ * - `nextOffset`: 다음 호출에 사용할 오프셋 값이에요. 더 가져올 연락처가 없으면 `null`이에요.
23
+ * - `done`: 모든 연락처를 다 가져왔는지 여부를 나타내요. 모두 가져왔다면 `true`예요.
24
+ *
25
+ * @signature
26
+ * ```typescript
27
+ * function fetchContacts({ size, offset, query }: {
28
+ * size: number;
29
+ * offset: number;
30
+ * query?: {
31
+ * contains?: string;
32
+ * };
33
+ * }): Promise<{
34
+ * result: ContactEntity[];
35
+ * nextOffset: number | null;
36
+ * done: boolean;
37
+ * }>;
38
+ * ```
39
+ *
40
+ * @example
41
+ * ### 특정 문자열이 포함된 연락처 목록 가져오기
42
+ *
43
+ * ```tsx
44
+ * import React, { useState } from 'react';
45
+ *
46
+ * import { fetchContacts, ContactEntity } from '@apps-in-toss/web-framework';
47
+ *
48
+ * // 특정 문자열을 포함한 연락처 목록을 가져와 화면에 표시하는 컴포넌트
49
+ * function ContactsList() {
50
+ * const [contacts, setContacts] = useState<{
51
+ * result: ContactEntity[];
52
+ * nextOffset: number | null;
53
+ * done: boolean;
54
+ * }>({
55
+ * result: [],
56
+ * nextOffset: null,
57
+ * done: false,
58
+ * });
59
+ *
60
+ * const handlePress = async () => {
61
+ * try {
62
+ * if (contacts.done) {
63
+ * console.log('모든 연락처를 가져왔어요.');
64
+ * return;
65
+ * }
66
+ *
67
+ * const response = await fetchContacts({
68
+ * size: 10,
69
+ * offset: contacts.nextOffset ?? 0,
70
+ * query: { contains: '김' },
71
+ * });
72
+ * setContacts((prev) => ({
73
+ * result: [...prev.result, ...response.result],
74
+ * nextOffset: response.nextOffset,
75
+ * done: response.done,
76
+ * }));
77
+ * } catch (error) {
78
+ * console.error('연락처를 가져오는 데 실패했어요:', error);
79
+ * }
80
+ * };
81
+ *
82
+ * return (
83
+ * <div>
84
+ * {contacts.result.map((contact, index) => (
85
+ * <span key={index}>{contact.name}: {contact.phoneNumber}</span>
86
+ * ))}
87
+ * <input type="button"
88
+ * value={contacts.done ? '모든 연락처를 가져왔어요.' : '다음 연락처 가져오기'}
89
+ * disabled={contacts.done}
90
+ * onClick={handlePress}
91
+ * />
92
+ * </div>
93
+ * );
94
+ * }
95
+ * ```
96
+ */
97
+ export declare function fetchContacts({ size, offset, query, }: {
98
+ size: number;
99
+ offset: number;
100
+ query?: {
101
+ contains?: string;
102
+ };
103
+ }): Promise<{
104
+ result: ContactEntity[];
105
+ nextOffset: number | null;
106
+ done: boolean;
107
+ }>;
108
+
109
+ export {};
@@ -0,0 +1,49 @@
1
+ export type HapticFeedbackType = "tickWeak" | "tap" | "tickMedium" | "softMedium" | "basicWeak" | "basicMedium" | "success" | "error" | "wiggle" | "confetti";
2
+ /**
3
+ * @public
4
+ * @category 인터렉션
5
+ * @name HapticFeedbackOptions
6
+ * @description
7
+ * generateHapticFeedback 함수에 전달할 햅틱진동의 타입을 나타내요. 진동타입의 종류는 다음과 같아요.
8
+ * ```typescript
9
+ * type HapticFeedbackType =
10
+ * | "tickWeak"
11
+ * | "tap"
12
+ * | "tickMedium"
13
+ * | "softMedium"
14
+ * | "basicWeak"
15
+ * | "basicMedium"
16
+ * | "success"
17
+ * | "error"
18
+ * | "wiggle"
19
+ * | "confetti";
20
+ * ```
21
+ * @typedef { type: HapticFeedbackType } HapticFeedbackOptions
22
+ * @typedef { "tickWeak" | "tap" | "tickMedium" | "softMedium" | "basicWeak" | "basicMedium" | "success" | "error" | "wiggle" | "confetti" } HapticFeedbackType
23
+ *
24
+ */
25
+ export interface HapticFeedbackOptions {
26
+ type: HapticFeedbackType;
27
+ }
28
+ /**
29
+ * @public
30
+ * @category 인터렉션
31
+ * @name generateHapticFeedback
32
+ * @description 디바이스에 햅틱 진동을 일으키는 함수예요. 예를 들어, 버튼 터치나 화면전환에 드라마틱한 효과를 주고 싶을 때 사용할 수 있어요. [HapticFeedbackOptions](/react-native/reference/@apps-in-toss/web-framework/인터렉션/HapticFeedbackOptions.html)에서 진동타입을 확인해 보세요.
33
+ * @returns {void}
34
+ *
35
+ * @example
36
+ * ### 버튼을 눌러 햅틱 일으키기
37
+ *
38
+ * ```tsx
39
+ *
40
+ * import { generateHapticFeedback } from '@apps-in-toss/web-framework';
41
+ *
42
+ * function GenerateHapticFeedback() {
43
+ * return <input type="button" value="햅틱" onClick={() => { generateHapticFeedback( { type: "tickWeak"}) }} />;
44
+ * }
45
+ * ```
46
+ */
47
+ export declare function generateHapticFeedback(options: HapticFeedbackOptions): Promise<void>;
48
+
49
+ export {};
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @public
3
+ * @category 클립보드
4
+ * @name getClipboardText
5
+ * @description 클립보드에 저장된 텍스트를 가져오는 함수예요. 복사된 텍스트를 읽어서 다른 작업에 활용할 수 있어요.
6
+ * @returns {Promise<string>} - 클립보드에 저장된 텍스트를 반환해요. 클립보드에 텍스트가 없으면 빈 문자열을 반환해요.
7
+ *
8
+ * @example
9
+ * ### 클립보드의 텍스트 가져오기
10
+ *
11
+ * ```tsx
12
+ * import React, { useState } from 'react';
13
+ *
14
+ * import { getClipboardText } from '@apps-in-toss/web-framework';
15
+ *
16
+ * // '붙여넣기' 버튼을 누르면 클립보드에 저장된 텍스트를 가져와 화면에 표시해요.
17
+ * function PasteButton() {
18
+ * const [text, setText] = useState('');
19
+ *
20
+ * const handlePress = async () => {
21
+ * try {
22
+ * const clipboardText = await getClipboardText();
23
+ * setText(clipboardText || '클립보드에 텍스트가 없어요.');
24
+ * } catch (error) {
25
+ * console.error('클립보드에서 텍스트를 가져오지 못했어요:', error);
26
+ * }
27
+ * };
28
+ *
29
+ * return (
30
+ * <div>
31
+ * <span>{text}</span>
32
+ * <input type="button" value="붙여넣기" onClick={handlePress} />
33
+ * </div>
34
+ * );
35
+ * }
36
+ * ```
37
+ */
38
+ export declare function getClipboardText(): Promise<string>;
39
+
40
+ export {};
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @public
3
+ * @category 위치 정보
4
+ * @name Accuracy
5
+ * @description 위치 정확도 옵션이에요.
6
+ */
7
+ export enum Accuracy {
8
+ /**
9
+ * 오차범위 3KM 이내
10
+ */
11
+ Lowest = 1,
12
+ /**
13
+ * 오차범위 1KM 이내
14
+ */
15
+ Low,
16
+ /**
17
+ * 오차범위 몇 백미터 이내
18
+ */
19
+ Balanced,
20
+ /**
21
+ * 오차범위 10M 이내
22
+ */
23
+ High,
24
+ /**
25
+ * 가장 높은 정확도
26
+ */
27
+ Highest,
28
+ /**
29
+ * 네비게이션을 위한 최고 정확도
30
+ */
31
+ BestForNavigation
32
+ }
33
+ /**
34
+ * @public
35
+ * @category 위치 정보
36
+ * @name Location
37
+ * @description 위치 정보를 나타내는 객체예요.
38
+ */
39
+ export interface Location {
40
+ /**
41
+ * Android에서만 지원하는 옵션이에요.
42
+ *
43
+ * - `FINE`: 정확한 위치
44
+ * - `COARSE`: 대략적인 위치
45
+ *
46
+ * @see https://developer.android.com/codelabs/approximate-location
47
+ */
48
+ accessLocation?: "FINE" | "COARSE";
49
+ /**
50
+ * 위치가 업데이트된 시점의 유닉스 타임스탬프예요.
51
+ */
52
+ timestamp: number;
53
+ /**
54
+ * @description 위치 정보를 나타내는 객체예요. 자세한 내용은 [LocationCoords](/react-native/reference/framework/Types/LocationCoords.html)을 참고해주세요.
55
+ */
56
+ coords: LocationCoords;
57
+ }
58
+ /**
59
+ * @public
60
+ * @category 위치 정보
61
+ * @name LocationCoords
62
+ * @description 세부 위치 정보를 나타내는 객체예요.
63
+ */
64
+ export interface LocationCoords {
65
+ /**
66
+ * 위도
67
+ */
68
+ latitude: number;
69
+ /**
70
+ * 경도
71
+ */
72
+ longitude: number;
73
+ /**
74
+ * 높이
75
+ */
76
+ altitude: number;
77
+ /**
78
+ * 위치 정확도
79
+ */
80
+ accuracy: number;
81
+ /**
82
+ * 고도 정확도
83
+ */
84
+ altitudeAccuracy: number;
85
+ /**
86
+ * 방향
87
+ */
88
+ heading: number;
89
+ }
90
+ export interface GetCurrentLocationOptions {
91
+ /**
92
+ * 위치 정보를 가져올 정확도 수준이에요.
93
+ */
94
+ accuracy: Accuracy;
95
+ }
96
+ /**
97
+ * @public
98
+ * @category 위치 정보
99
+ * @name getCurrentLocation
100
+ * @description 디바이스의 현재 위치 정보를 가져오는 함수예요.
101
+ * 위치 기반 서비스를 구현할 때 사용되고, 한 번만 호출되어 현재 위치를 즉시 반환해요.
102
+ * 예를 들어 지도 앱에서 사용자의 현재 위치를 한 번만 가져올 때, 날씨 앱에서 사용자의 위치를 기반으로 기상 정보를 제공할 때, 매장 찾기 기능에서 사용자의 위치를 기준으로 가까운 매장을 검색할 때 사용하면 유용해요.
103
+ *
104
+ * @param {GetCurrentLocationOptions} options 위치 정보를 가져올 때 사용하는 옵션 객체예요.
105
+ * @param {Accuracy} [options.accuracy] 위치 정보의 정확도 수준이에요. 정확도는 `Accuracy` 타입으로 설정돼요.
106
+ * @returns {Promise<Location>} 디바이스의 위치 정보가 담긴 객체를 반환해요. 자세한 내용은 [Location](/react-native/reference/framework/Types/Location.html)을 참고해주세요.
107
+ *
108
+ * @example
109
+ * ### 디바이스의 현재 위치 정보 가져오기
110
+ *
111
+ * ```tsx
112
+ * import React, { useState } from 'react';
113
+ *
114
+ * import { getCurrentLocation } from '@apps-in-toss/web-framework';
115
+ *
116
+ * // 현재 위치 정보를 가져와 화면에 표시하는 컴포넌트
117
+ * function CurrentPosition() {
118
+ * const [position, setPosition] = useState(null);
119
+ *
120
+ * const handlePress = async () => {
121
+ * try {
122
+ * const response = await getCurrentLocation({ accuracy: Accuracy.Balanced });
123
+ * setPosition(response);
124
+ * } catch (error) {
125
+ * console.error('위치 정보를 가져오는 데 실패했어요:', error);
126
+ * }
127
+ * };
128
+ *
129
+ * return (
130
+ * <div>
131
+ * {position ? (
132
+ * <span>위치: {position.coords.latitude}, {position.coords.longitude}</span>
133
+ * ) : (
134
+ * <span>위치 정보를 아직 가져오지 않았어요</span>
135
+ * )}
136
+ * <input type="button" value="현재 위치 정보 가져오기" onClick={handlePress} />
137
+ * </div>
138
+ * );
139
+ * }
140
+ * ```
141
+ */
142
+ export declare function getCurrentLocation(options: GetCurrentLocationOptions): Promise<Location>;
143
+
144
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @public
3
+ * @category 환경 확인
4
+ * @kind function
5
+ * @name getDeviceId
6
+ * @description
7
+ * 사용 중인 기기의 고유 식별자를 문자열로 반환해요.
8
+ *
9
+ * 이 함수는 현재 사용 중인 기기의 고유 식별자를 문자열로 반환해요. 기기별로 설정이나 데이터를 저장하거나 사용자의 기기를 식별해서 로그를 기록하고 분석하는 데 사용할 수 있어요. 같은 사용자의 여러 기기를 구분하는 데도 유용해요.
10
+ *
11
+ * @returns {string} 기기의 고유 식별자를 나타내는 문자열이에요.
12
+ *
13
+ * @example
14
+ * ### 기기 고유 식별자 가져오기
15
+ *
16
+ * ```tsx
17
+ * import { getDeviceId } from '@apps-in-toss/web-framework';
18
+ *
19
+ *
20
+ * function MyPage() {
21
+ * const id = getDeviceId();
22
+ *
23
+ * return (
24
+ * <span>사용자의 기기 고유 식별자: {id}</span>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export declare function getDeviceId(): string;
30
+
31
+ export {};