@simplysm/capacitor-plugin-intent 14.0.51 → 14.0.53
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/package.json +1 -1
- package/README.md +0 -203
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
# @simplysm/capacitor-plugin-intent
|
|
2
|
-
|
|
3
|
-
Capacitor Intent 플러그인. 브로드캐스트 송수신, 실행 인텐트 조회, 새 인텐트 이벤트 수신, `startActivityForResult`를 제공한다. 산업용 디바이스 연동(바코드 스캐너, PDA 등)을 위해 설계되었다.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @simplysm/capacitor-plugin-intent
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## API Overview
|
|
12
|
-
|
|
13
|
-
### 인텐트
|
|
14
|
-
|
|
15
|
-
| API | Type | Description |
|
|
16
|
-
|-----|------|-------------|
|
|
17
|
-
| `IntentResult` | interface | 브로드캐스트/인텐트 결과 데이터 |
|
|
18
|
-
| `StartActivityForResultOptions` | interface | startActivityForResult 호출 옵션 |
|
|
19
|
-
| `StartActivityForResultResult` | interface | startActivityForResult 반환 결과 |
|
|
20
|
-
| `IntentPlugin` | interface | Capacitor 네이티브 플러그인 인터페이스 |
|
|
21
|
-
| `Intent` | abstract class | 인텐트 플러그인 정적 파사드 |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## `IntentResult`
|
|
26
|
-
|
|
27
|
-
브로드캐스트 또는 인텐트 결과 데이터를 나타내는 인터페이스.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
export interface IntentResult {
|
|
31
|
-
action?: string;
|
|
32
|
-
extras?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
| Field | Type | Description |
|
|
37
|
-
|-------|------|-------------|
|
|
38
|
-
| `action` | `string \| undefined` | 브로드캐스트 액션 |
|
|
39
|
-
| `extras` | `Record<string, unknown> \| undefined` | 추가 데이터 |
|
|
40
|
-
|
|
41
|
-
## `StartActivityForResultOptions`
|
|
42
|
-
|
|
43
|
-
`startActivityForResult` 호출 시 전달하는 옵션 인터페이스.
|
|
44
|
-
|
|
45
|
-
```typescript
|
|
46
|
-
export interface StartActivityForResultOptions {
|
|
47
|
-
action?: string;
|
|
48
|
-
uri?: string;
|
|
49
|
-
extras?: Record<string, unknown>;
|
|
50
|
-
type?: string;
|
|
51
|
-
packageName?: string;
|
|
52
|
-
className?: string;
|
|
53
|
-
flags?: number;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
| Field | Type | Description |
|
|
58
|
-
|-------|------|-------------|
|
|
59
|
-
| `action` | `string \| undefined` | Intent 액션 |
|
|
60
|
-
| `uri` | `string \| undefined` | Intent 데이터 URI |
|
|
61
|
-
| `extras` | `Record<string, unknown> \| undefined` | 추가 데이터 |
|
|
62
|
-
| `type` | `string \| undefined` | MIME type |
|
|
63
|
-
| `packageName` | `string \| undefined` | 특정 앱 지정 |
|
|
64
|
-
| `className` | `string \| undefined` | 특정 Activity 지정 |
|
|
65
|
-
| `flags` | `number \| undefined` | Intent flags |
|
|
66
|
-
|
|
67
|
-
## `StartActivityForResultResult`
|
|
68
|
-
|
|
69
|
-
`startActivityForResult` 호출의 반환 결과 인터페이스.
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
export interface StartActivityForResultResult {
|
|
73
|
-
resultCode: number;
|
|
74
|
-
data?: {
|
|
75
|
-
action?: string;
|
|
76
|
-
uri?: string;
|
|
77
|
-
extras?: Record<string, unknown>;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
| Field | Type | Description |
|
|
83
|
-
|-------|------|-------------|
|
|
84
|
-
| `resultCode` | `number` | 결과 코드 (`-1`: RESULT_OK, `0`: RESULT_CANCELED) |
|
|
85
|
-
| `data` | `object \| undefined` | 결과 데이터 |
|
|
86
|
-
| `data.action` | `string \| undefined` | 결과 인텐트 액션 |
|
|
87
|
-
| `data.uri` | `string \| undefined` | 결과 인텐트 데이터 URI |
|
|
88
|
-
| `data.extras` | `Record<string, unknown> \| undefined` | 결과 인텐트 추가 데이터 |
|
|
89
|
-
|
|
90
|
-
## `IntentPlugin`
|
|
91
|
-
|
|
92
|
-
Capacitor 네이티브 플러그인 인터페이스. 직접 사용하지 않고 `Intent` 파사드를 통해 접근한다.
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
export interface IntentPlugin {
|
|
96
|
-
subscribe(
|
|
97
|
-
options: { filters: string[] },
|
|
98
|
-
callback: (result: IntentResult) => void,
|
|
99
|
-
): Promise<{ id: string }>;
|
|
100
|
-
unsubscribe(options: { id: string }): Promise<void>;
|
|
101
|
-
unsubscribeAll(): Promise<void>;
|
|
102
|
-
send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
|
|
103
|
-
getLaunchIntent(): Promise<IntentResult>;
|
|
104
|
-
addListener(
|
|
105
|
-
eventName: "newIntent",
|
|
106
|
-
listenerFunc: (data: IntentResult) => void,
|
|
107
|
-
): Promise<PluginListenerHandle>;
|
|
108
|
-
removeAllListeners(): Promise<void>;
|
|
109
|
-
startActivityForResult(
|
|
110
|
-
options: StartActivityForResultOptions,
|
|
111
|
-
): Promise<StartActivityForResultResult>;
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
| Method | Parameters | Return | Description |
|
|
116
|
-
|--------|-----------|--------|-------------|
|
|
117
|
-
| `subscribe` | `{ filters }, callback` | `Promise<{ id: string }>` | 브로드캐스트 수신기 등록 |
|
|
118
|
-
| `unsubscribe` | `{ id }` | `Promise<void>` | 특정 수신기 구독 해제 |
|
|
119
|
-
| `unsubscribeAll` | 없음 | `Promise<void>` | 모든 수신기 구독 해제 |
|
|
120
|
-
| `send` | `{ action, extras? }` | `Promise<void>` | 브로드캐스트 전송 |
|
|
121
|
-
| `getLaunchIntent` | 없음 | `Promise<IntentResult>` | 실행 인텐트 조회 |
|
|
122
|
-
| `addListener` | `"newIntent", listenerFunc` | `Promise<PluginListenerHandle>` | 새 인텐트 이벤트 리스너 등록 |
|
|
123
|
-
| `removeAllListeners` | 없음 | `Promise<void>` | 모든 이벤트 리스너 제거 |
|
|
124
|
-
| `startActivityForResult` | `options` | `Promise<StartActivityForResultResult>` | 외부 Activity 실행 후 결과 수신 |
|
|
125
|
-
|
|
126
|
-
## `Intent`
|
|
127
|
-
|
|
128
|
-
Android 인텐트 플러그인 정적 파사드 클래스. 브로드캐스트 송수신, 실행 인텐트 조회, 산업용 디바이스 연동을 위한 기능을 제공한다.
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
export abstract class Intent {
|
|
132
|
-
static async subscribe(
|
|
133
|
-
filters: string[],
|
|
134
|
-
callback: (result: IntentResult) => void,
|
|
135
|
-
): Promise<() => Promise<void>>;
|
|
136
|
-
static async unsubscribeAll(): Promise<void>;
|
|
137
|
-
static async send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
|
|
138
|
-
static async getLaunchIntent(): Promise<IntentResult>;
|
|
139
|
-
static async addListener(
|
|
140
|
-
eventName: "newIntent",
|
|
141
|
-
callback: (result: IntentResult) => void,
|
|
142
|
-
): Promise<PluginListenerHandle>;
|
|
143
|
-
static async removeAllListeners(): Promise<void>;
|
|
144
|
-
static async startActivityForResult(
|
|
145
|
-
options: StartActivityForResultOptions,
|
|
146
|
-
): Promise<StartActivityForResultResult>;
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
| Method | Parameters | Return | Description |
|
|
151
|
-
|--------|-----------|--------|-------------|
|
|
152
|
-
| `subscribe` | `filters: string[], callback` | `Promise<() => Promise<void>>` | 브로드캐스트 수신기 등록. 구독 해제 함수를 반환한다. 초기 resolve 콜백(`action == null`)은 자동 필터링된다. |
|
|
153
|
-
| `unsubscribeAll` | 없음 | `Promise<void>` | 모든 브로드캐스트 수신기 구독 해제 |
|
|
154
|
-
| `send` | `{ action, extras? }` | `Promise<void>` | 브로드캐스트 전송 |
|
|
155
|
-
| `getLaunchIntent` | 없음 | `Promise<IntentResult>` | 앱 실행 인텐트 조회 |
|
|
156
|
-
| `addListener` | `"newIntent", callback` | `Promise<PluginListenerHandle>` | 앱 실행 중 수신되는 새 인텐트 이벤트 리스너 등록. `handle.remove()`로 해제한다. |
|
|
157
|
-
| `removeAllListeners` | 없음 | `Promise<void>` | 모든 이벤트 리스너 제거 |
|
|
158
|
-
| `startActivityForResult` | `options: StartActivityForResultOptions` | `Promise<StartActivityForResultResult>` | 외부 Activity를 실행하고 결과를 수신한다 |
|
|
159
|
-
|
|
160
|
-
## Usage Examples
|
|
161
|
-
|
|
162
|
-
### 브로드캐스트 수신 (바코드 스캐너 연동)
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
import { Intent } from "@simplysm/capacitor-plugin-intent";
|
|
166
|
-
|
|
167
|
-
const unsub = await Intent.subscribe(
|
|
168
|
-
["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
169
|
-
(result) => {
|
|
170
|
-
// result.extras에서 스캔 데이터 처리
|
|
171
|
-
},
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
// 구독 해제
|
|
175
|
-
await unsub();
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### 브로드캐스트 전송
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
import { Intent } from "@simplysm/capacitor-plugin-intent";
|
|
182
|
-
|
|
183
|
-
await Intent.send({
|
|
184
|
-
action: "com.symbol.datawedge.api.ACTION",
|
|
185
|
-
extras: {
|
|
186
|
-
"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### startActivityForResult
|
|
192
|
-
|
|
193
|
-
```typescript
|
|
194
|
-
import { Intent } from "@simplysm/capacitor-plugin-intent";
|
|
195
|
-
|
|
196
|
-
const result = await Intent.startActivityForResult({
|
|
197
|
-
action: "com.example.PAY",
|
|
198
|
-
extras: { amount: 1000 },
|
|
199
|
-
});
|
|
200
|
-
if (result.resultCode === -1) {
|
|
201
|
-
// RESULT_OK
|
|
202
|
-
}
|
|
203
|
-
```
|