@simplysm/capacitor-plugin-intent 14.0.23 → 14.0.25

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/package.json +1 -1
  2. package/README.md +0 -203
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-intent",
3
- "version": "14.0.23",
3
+ "version": "14.0.25",
4
4
  "description": "심플리즘 패키지 - Capacitor Intent 플러그인",
5
5
  "author": "심플리즘",
6
6
  "license": "Apache-2.0",
package/README.md DELETED
@@ -1,203 +0,0 @@
1
- # @simplysm/capacitor-plugin-intent
2
-
3
- Capacitor plugin for Android intent handling. Supports broadcast send/receive, launch intent retrieval, event listeners for new intents, and `startActivityForResult`. Designed for industrial device integration (barcode scanners, PDA devices, etc.).
4
-
5
- - **Android**: Full intent support
6
- - **Browser**: Web fallback for development
7
-
8
- ## Installation
9
-
10
- ```bash
11
- npm install @simplysm/capacitor-plugin-intent
12
- ```
13
-
14
- ## API Overview
15
-
16
- ### Interfaces
17
-
18
- | API | Type | Description |
19
- |-----|------|-------------|
20
- | `IntentResult` | interface | Data received from a broadcast or launch intent |
21
- | `StartActivityForResultOptions` | interface | Options for starting an Android activity and awaiting its result |
22
- | `StartActivityForResultResult` | interface | Result returned from a started activity |
23
- | `IntentPlugin` | interface | Native plugin interface for intent operations |
24
-
25
- ### Classes
26
-
27
- | API | Type | Description |
28
- |-----|------|-------------|
29
- | `Intent` | class | Static API for broadcast send/receive, launch intents, and activity results |
30
-
31
- ## `IntentResult`
32
-
33
- Data received from a broadcast or launch intent.
34
-
35
- ```typescript
36
- interface IntentResult {
37
- action?: string;
38
- extras?: Record<string, unknown>;
39
- }
40
- ```
41
-
42
- | Field | Type | Description |
43
- |-------|------|-------------|
44
- | `action` | `string \| undefined` | The intent action string (e.g. `"com.example.SCAN_RESULT"`) |
45
- | `extras` | `Record<string, unknown> \| undefined` | Key-value map of intent extras |
46
-
47
- ## `StartActivityForResultOptions`
48
-
49
- Options for launching an Android activity and awaiting its result.
50
-
51
- ```typescript
52
- interface StartActivityForResultOptions {
53
- action?: string;
54
- uri?: string;
55
- extras?: Record<string, unknown>;
56
- type?: string;
57
- packageName?: string;
58
- className?: string;
59
- flags?: number;
60
- }
61
- ```
62
-
63
- | Field | Type | Description |
64
- |-------|------|-------------|
65
- | `action` | `string \| undefined` | Intent action (e.g. `"android.intent.action.VIEW"`) |
66
- | `uri` | `string \| undefined` | Data URI to pass to the intent |
67
- | `extras` | `Record<string, unknown> \| undefined` | Extra key-value pairs to include |
68
- | `type` | `string \| undefined` | MIME type (e.g. `"image/*"`) |
69
- | `packageName` | `string \| undefined` | Target package name for an explicit intent |
70
- | `className` | `string \| undefined` | Target Activity class name for an explicit intent |
71
- | `flags` | `number \| undefined` | Intent flags bitmask |
72
-
73
- ## `StartActivityForResultResult`
74
-
75
- Result returned when a launched activity finishes.
76
-
77
- ```typescript
78
- interface StartActivityForResultResult {
79
- resultCode: number;
80
- data?: {
81
- action?: string;
82
- uri?: string;
83
- extras?: Record<string, unknown>;
84
- };
85
- }
86
- ```
87
-
88
- | Field | Type | Description |
89
- |-------|------|-------------|
90
- | `resultCode` | `number` | Android result code (`RESULT_OK = -1`, `RESULT_CANCELED = 0`) |
91
- | `data` | `{ action?: string; uri?: string; extras?: Record<string, unknown> } \| undefined` | Optional data returned by the activity, including its action, URI, and extras |
92
-
93
- ## `IntentPlugin`
94
-
95
- Native plugin interface for intent operations. Use the `Intent` class for a simplified API.
96
-
97
- ```typescript
98
- interface IntentPlugin {
99
- subscribe(
100
- options: { filters: string[] },
101
- callback: (result: IntentResult) => void,
102
- ): Promise<{ id: string }>;
103
- unsubscribe(options: { id: string }): Promise<void>;
104
- unsubscribeAll(): Promise<void>;
105
- send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
106
- getLaunchIntent(): Promise<IntentResult>;
107
- addListener(
108
- eventName: "newIntent",
109
- listenerFunc: (data: IntentResult) => void,
110
- ): Promise<PluginListenerHandle>;
111
- removeAllListeners(): Promise<void>;
112
- startActivityForResult(
113
- options: StartActivityForResultOptions,
114
- ): Promise<StartActivityForResultResult>;
115
- }
116
- ```
117
-
118
- | Method | Signature | Description |
119
- |--------|-----------|-------------|
120
- | `subscribe` | `(options: { filters: string[] }, callback: (result: IntentResult) => void) => Promise<{ id: string }>` | Register a broadcast receiver for the given action filters |
121
- | `unsubscribe` | `(options: { id: string }) => Promise<void>` | Unregister a broadcast receiver by subscription ID |
122
- | `unsubscribeAll` | `() => Promise<void>` | Unregister all broadcast receivers |
123
- | `send` | `(options: { action: string; extras?: Record<string, unknown> }) => Promise<void>` | Send a broadcast intent |
124
- | `getLaunchIntent` | `() => Promise<IntentResult>` | Get the intent that launched the current activity |
125
- | `addListener` | `(eventName: "newIntent", listenerFunc: (data: IntentResult) => void) => Promise<PluginListenerHandle>` | Listen for new intents delivered to the activity |
126
- | `removeAllListeners` | `() => Promise<void>` | Remove all event listeners |
127
- | `startActivityForResult` | `(options: StartActivityForResultOptions) => Promise<StartActivityForResultResult>` | Start an activity and await its result |
128
-
129
- ## `Intent`
130
-
131
- Abstract class with static methods for Android intent operations. Designed for industrial devices such as barcode scanners and PDAs.
132
-
133
- ```typescript
134
- abstract class Intent {
135
- static async subscribe(
136
- filters: string[],
137
- callback: (result: IntentResult) => void,
138
- ): Promise<() => Promise<void>>;
139
- static async unsubscribeAll(): Promise<void>;
140
- static async send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
141
- static async getLaunchIntent(): Promise<IntentResult>;
142
- static async addListener(
143
- eventName: "newIntent",
144
- callback: (result: IntentResult) => void,
145
- ): Promise<PluginListenerHandle>;
146
- static async removeAllListeners(): Promise<void>;
147
- static async startActivityForResult(
148
- options: StartActivityForResultOptions,
149
- ): Promise<StartActivityForResultResult>;
150
- }
151
- ```
152
-
153
- | Method | Signature | Description |
154
- |--------|-----------|-------------|
155
- | `subscribe` | `static async subscribe(filters: string[], callback: (result: IntentResult) => void): Promise<() => Promise<void>>` | Register a broadcast receiver for the given action filters. Returns an async unsubscribe function. |
156
- | `unsubscribeAll` | `static async unsubscribeAll(): Promise<void>` | Unregister all active broadcast receivers |
157
- | `send` | `static async send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>` | Send a broadcast intent with the specified action and optional extras |
158
- | `getLaunchIntent` | `static async getLaunchIntent(): Promise<IntentResult>` | Retrieve the intent that launched the current activity |
159
- | `addListener` | `static async addListener(eventName: "newIntent", callback: (result: IntentResult) => void): Promise<PluginListenerHandle>` | Add a listener for new intents delivered to the activity via `onNewIntent`. Call `handle.remove()` to unregister. |
160
- | `removeAllListeners` | `static async removeAllListeners(): Promise<void>` | Remove all registered event listeners |
161
- | `startActivityForResult` | `static async startActivityForResult(options: StartActivityForResultOptions): Promise<StartActivityForResultResult>` | Start an Android activity and return its result when it finishes |
162
-
163
- ## Usage Examples
164
-
165
- ### Subscribe to barcode scanner broadcasts
166
-
167
- ```typescript
168
- import { Intent } from "@simplysm/capacitor-plugin-intent";
169
-
170
- const unsubscribe = await Intent.subscribe(
171
- ["com.symbol.datawedge.api.RESULT_ACTION"],
172
- (result) => {
173
- const barcode = result.extras?.["com.symbol.datawedge.data_string"];
174
- // handle barcode
175
- },
176
- );
177
-
178
- // Later, stop listening
179
- await unsubscribe();
180
- ```
181
-
182
- ### Send a broadcast and start an activity for result
183
-
184
- ```typescript
185
- import { Intent } from "@simplysm/capacitor-plugin-intent";
186
-
187
- // Send a broadcast
188
- await Intent.send({
189
- action: "com.symbol.datawedge.api.ACTION",
190
- extras: {
191
- "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
192
- },
193
- });
194
-
195
- // Start an activity for result
196
- const result = await Intent.startActivityForResult({
197
- action: "com.example.PAY",
198
- extras: { amount: 1000 },
199
- });
200
- if (result.resultCode === -1) {
201
- // RESULT_OK - payment succeeded
202
- }
203
- ```