@simplysm/capacitor-plugin-broadcast 13.0.96 → 13.0.98

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.
Files changed (2) hide show
  1. package/README.md +89 -100
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,144 +1,133 @@
1
1
  # @simplysm/capacitor-plugin-broadcast
2
2
 
3
- Capacitor Android 브로드캐스트 리시버 플러그인. 바코드 스캐너, PDA 산업용 기기의 인텐트 브로드캐스트를 수신/발신한다.
3
+ Capacitor Broadcast Plugin -- send and receive Android broadcast intents for industrial device integration (barcode scanners, PDAs, etc.).
4
4
 
5
- ## 설치
5
+ ## Installation
6
6
 
7
7
  ```bash
8
8
  npm install @simplysm/capacitor-plugin-broadcast
9
9
  ```
10
10
 
11
- **Peer:** `@capacitor/core` ^7.4.4
12
- **외부 의존성 없음**
11
+ ## API Overview
13
12
 
14
- ## Export 목록
13
+ ### Types
15
14
 
16
- ```typescript
17
- // index.ts
18
- export { Broadcast } from "./Broadcast";
19
- export type { BroadcastPlugin, BroadcastResult } from "./BroadcastPlugin";
20
- ```
15
+ | API | Type | Description |
16
+ |-----|------|-------------|
17
+ | `BroadcastResult` | interface | Broadcast result containing `action` and `extras` |
21
18
 
22
- ## 주요 사용법
19
+ ### Interfaces
23
20
 
24
- ### 브로드캐스트 구독
21
+ | API | Type | Description |
22
+ |-----|------|-------------|
23
+ | `BroadcastPlugin` | interface | Low-level Capacitor plugin interface for broadcast operations |
25
24
 
26
- 특정 인텐트 액션 필터로 구독하고, 브로드캐스트 수신 시 콜백을 실행한다.
27
-
28
- ```typescript
29
- import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
25
+ ### Classes
30
26
 
31
- // 구독 (unsubscribe 함수 반환)
32
- const unsubscribe = await Broadcast.subscribe(
33
- ["com.symbol.datawedge.api.RESULT_ACTION", "com.example.SCAN_RESULT"],
34
- (result) => {
35
- // result.action: 수신된 액션 이름
36
- // result.extras: 추가 데이터 (Record<string, unknown>)
37
- },
38
- );
27
+ | API | Type | Description |
28
+ |-----|------|-------------|
29
+ | `Broadcast` | abstract class | Android broadcast send/receive operations |
39
30
 
40
- // 구독 해제
41
- await unsubscribe();
31
+ ## `BroadcastResult`
42
32
 
43
- // 전체 구독 해제
44
- await Broadcast.unsubscribeAll();
33
+ ```typescript
34
+ interface BroadcastResult {
35
+ /** Broadcast action */
36
+ action?: string;
37
+ /** Extra data */
38
+ extras?: Record<string, unknown>;
39
+ }
45
40
  ```
46
41
 
47
- ### 브로드캐스트 전송
42
+ ## `BroadcastPlugin`
48
43
 
49
44
  ```typescript
50
- await Broadcast.send({
51
- action: "com.symbol.datawedge.api.ACTION",
52
- extras: {
53
- "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
54
- },
55
- });
45
+ interface BroadcastPlugin {
46
+ subscribe(
47
+ options: { filters: string[] },
48
+ callback: (result: BroadcastResult) => void,
49
+ ): Promise<{ id: string }>;
50
+ unsubscribe(options: { id: string }): Promise<void>;
51
+ unsubscribeAll(): Promise<void>;
52
+ send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
53
+ getLaunchIntent(): Promise<BroadcastResult>;
54
+ addListener(
55
+ eventName: "newIntent",
56
+ listenerFunc: (data: BroadcastResult) => void,
57
+ ): Promise<PluginListenerHandle>;
58
+ removeAllListeners(): Promise<void>;
59
+ }
56
60
  ```
57
61
 
58
- ### 런치 인텐트 조회
62
+ Low-level Capacitor plugin interface. Use `Broadcast` static methods instead of calling this directly.
59
63
 
60
- 앱을 시작한 인텐트 정보를 가져온다.
64
+ ## `Broadcast`
61
65
 
62
66
  ```typescript
63
- const intent = await Broadcast.getLaunchIntent();
64
- // { action?: string, extras?: Record<string, unknown> }
67
+ abstract class Broadcast {
68
+ static async subscribe(
69
+ filters: string[],
70
+ callback: (result: BroadcastResult) => void,
71
+ ): Promise<() => Promise<void>>;
72
+
73
+ static async unsubscribeAll(): Promise<void>;
74
+
75
+ static async send(options: {
76
+ action: string;
77
+ extras?: Record<string, unknown>;
78
+ }): Promise<void>;
79
+
80
+ static async getLaunchIntent(): Promise<BroadcastResult>;
81
+
82
+ static async addListener(
83
+ eventName: "newIntent",
84
+ callback: (result: BroadcastResult) => void,
85
+ ): Promise<PluginListenerHandle>;
86
+
87
+ static async removeAllListeners(): Promise<void>;
88
+ }
65
89
  ```
66
90
 
67
- ### 인텐트 리스너
91
+ ## Usage Examples
68
92
 
69
- 앱이 실행 중일 때 수신되는 새 인텐트를 감지한다 (`onNewIntent`).
93
+ ### Subscribe to broadcasts
70
94
 
71
95
  ```typescript
72
- import type { PluginListenerHandle } from "@capacitor/core";
96
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
73
97
 
74
- const handle: PluginListenerHandle = await Broadcast.addListener(
75
- "newIntent",
76
- (data) => {
77
- // data.action, data.extras
98
+ const unsub = await Broadcast.subscribe(
99
+ ["com.symbol.datawedge.api.RESULT_ACTION"],
100
+ (result) => {
101
+ // handle result.action, result.extras
78
102
  },
79
103
  );
80
104
 
81
- // 리스너 해제
82
- await handle.remove();
83
-
84
- // 전체 리스너 해제
85
- await Broadcast.removeAllListeners();
105
+ // Later: unsubscribe
106
+ await unsub();
86
107
  ```
87
108
 
88
- ## API 레퍼런스
109
+ ### Send a broadcast
89
110
 
90
- ### `Broadcast` (abstract class, static 메서드)
111
+ ```typescript
112
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
91
113
 
92
- | 메서드 | 시그니처 | 설명 |
93
- |--------|----------|------|
94
- | `subscribe` | `(filters: string[], callback: (result: BroadcastResult) => void) => Promise<() => Promise<void>>` | 브로드캐스트 구독. unsubscribe 함수 반환 |
95
- | `unsubscribeAll` | `() => Promise<void>` | 모든 구독 해제 |
96
- | `send` | `(options: { action: string; extras?: Record<string, unknown> }) => Promise<void>` | 브로드캐스트 전송 |
97
- | `getLaunchIntent` | `() => Promise<BroadcastResult>` | 런치 인텐트 조회 |
98
- | `addListener` | `(eventName: "newIntent", callback: (result: BroadcastResult) => void) => Promise<PluginListenerHandle>` | 이벤트 리스너 등록 |
99
- | `removeAllListeners` | `() => Promise<void>` | 모든 이벤트 리스너 해제 |
114
+ await Broadcast.send({
115
+ action: "com.symbol.datawedge.api.ACTION",
116
+ extras: {
117
+ "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
118
+ },
119
+ });
120
+ ```
100
121
 
101
- ### `BroadcastResult` (interface)
122
+ ### Listen for new intents
102
123
 
103
124
  ```typescript
104
- interface BroadcastResult {
105
- action?: string; // 브로드캐스트 액션 이름
106
- extras?: Record<string, unknown>; // 추가 데이터
107
- }
108
- ```
109
-
110
- ### `BroadcastPlugin` (interface, 저수준)
125
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
111
126
 
112
- `Broadcast` 클래스가 래핑하는 Capacitor 플러그인 인터페이스. 직접 사용할 일은 거의 없다.
127
+ const handle = await Broadcast.addListener("newIntent", (result) => {
128
+ // handle intent
129
+ });
113
130
 
114
- ```typescript
115
- interface BroadcastPlugin {
116
- subscribe(options: { filters: string[] }, callback: (result: BroadcastResult) => void): Promise<{ id: string }>;
117
- unsubscribe(options: { id: string }): Promise<void>;
118
- unsubscribeAll(): Promise<void>;
119
- send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
120
- getLaunchIntent(): Promise<BroadcastResult>;
121
- addListener(eventName: "newIntent", listenerFunc: (data: BroadcastResult) => void): Promise<PluginListenerHandle>;
122
- removeAllListeners(): Promise<void>;
123
- }
131
+ // Later: remove listener
132
+ await handle.remove();
124
133
  ```
125
-
126
- ## 플랫폼 지원
127
-
128
- | 기능 | Android | Web |
129
- |------|---------|-----|
130
- | 구독 | BroadcastReceiver + IntentFilter 등록 | 경고 후 스텁 반환 (`id: "web-stub"`) |
131
- | 구독 해제 | `unregisterReceiver` | no-op |
132
- | 전송 | `sendBroadcast(intent)` | 경고 후 no-op |
133
- | 런치 인텐트 | `Activity.getIntent()` | 빈 객체 `{}` 반환 |
134
- | 새 인텐트 | `handleOnNewIntent` -> `notifyListeners` | Capacitor WebPlugin 기본 동작 |
135
-
136
- ## Android 네이티브 구현
137
-
138
- - **패키지:** `kr.co.simplysm.capacitor.broadcast`
139
- - **플러그인명:** `Broadcast`
140
- - `subscribe`: `RETURN_CALLBACK` 방식 (`call.setKeepAlive`), UUID 기반 receiver ID 관리
141
- - **전송 시 extras 타입 (JSON -> Intent):** `String`, `Integer`, `Long`, `Double`, `Boolean`, `JSONArray`(-> `String[]`), `JSONObject`(-> `Bundle`)
142
- - **수신 시 extras 타입 (Intent -> JSON):** `String`, `Integer`, `Long`, `Double`, `Float`(-> `Double`), `Boolean`, `Bundle`(-> 재귀 변환), `String[]`, `int[]`, `Parcelable`(-> `toString()`), `Parcelable[]`, 기타(-> `toString()`)
143
- - Android 13+: `RECEIVER_EXPORTED` 플래그 사용
144
- - `handleOnDestroy`에서 모든 receiver 자동 해제
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-broadcast",
3
- "version": "13.0.96",
3
+ "version": "13.0.98",
4
4
  "description": "Simplysm Package - Capacitor Broadcast Plugin",
5
5
  "author": "simplysm",
6
6
  "license": "MIT",