@simplysm/capacitor-plugin-broadcast 13.0.97 → 13.0.99
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 +84 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-broadcast
|
|
2
|
+
|
|
3
|
+
Simplysm Package - Capacitor Broadcast Plugin. Provides Android Broadcast send/receive functionality for industrial device integration (barcode scanners, PDAs, etc.).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-broadcast
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
### Broadcast
|
|
14
|
+
|
|
15
|
+
| API | Type | Description |
|
|
16
|
+
|-----|------|-------------|
|
|
17
|
+
| `Broadcast` | class | Android Broadcast send/receive plugin (static methods) |
|
|
18
|
+
| `BroadcastPlugin` | interface | Low-level Capacitor plugin interface for broadcast |
|
|
19
|
+
| `BroadcastResult` | interface | Broadcast result data |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### `BroadcastResult`
|
|
24
|
+
|
|
25
|
+
| Field | Type | Description |
|
|
26
|
+
|-------|------|-------------|
|
|
27
|
+
| `action` | `string \| undefined` | Broadcast action |
|
|
28
|
+
| `extras` | `Record<string, unknown> \| undefined` | Extra data |
|
|
29
|
+
|
|
30
|
+
### `BroadcastPlugin`
|
|
31
|
+
|
|
32
|
+
| Method | Signature | Description |
|
|
33
|
+
|--------|-----------|-------------|
|
|
34
|
+
| `subscribe` | `(options: { filters: string[] }, callback: (result: BroadcastResult) => void) => Promise<{ id: string }>` | Register broadcast receiver |
|
|
35
|
+
| `unsubscribe` | `(options: { id: string }) => Promise<void>` | Unsubscribe a specific broadcast receiver |
|
|
36
|
+
| `unsubscribeAll` | `() => Promise<void>` | Unsubscribe all broadcast receivers |
|
|
37
|
+
| `send` | `(options: { action: string; extras?: Record<string, unknown> }) => Promise<void>` | Send broadcast |
|
|
38
|
+
| `getLaunchIntent` | `() => Promise<BroadcastResult>` | Get launch intent |
|
|
39
|
+
| `addListener` | `(eventName: "newIntent", listenerFunc: (data: BroadcastResult) => void) => Promise<PluginListenerHandle>` | Register listener for new intents |
|
|
40
|
+
| `removeAllListeners` | `() => Promise<void>` | Remove all event listeners |
|
|
41
|
+
|
|
42
|
+
### `Broadcast`
|
|
43
|
+
|
|
44
|
+
Abstract class with static methods for Android Broadcast send/receive.
|
|
45
|
+
|
|
46
|
+
| Method | Signature | Description |
|
|
47
|
+
|--------|-----------|-------------|
|
|
48
|
+
| `subscribe` | `(filters: string[], callback: (result: BroadcastResult) => void) => Promise<() => Promise<void>>` | Register broadcast receiver; returns unsubscribe function |
|
|
49
|
+
| `unsubscribeAll` | `() => Promise<void>` | Unsubscribe all broadcast receivers |
|
|
50
|
+
| `send` | `(options: { action: string; extras?: Record<string, unknown> }) => Promise<void>` | Send broadcast |
|
|
51
|
+
| `getLaunchIntent` | `() => Promise<BroadcastResult>` | Get launch intent |
|
|
52
|
+
| `addListener` | `(eventName: "newIntent", callback: (result: BroadcastResult) => void) => Promise<PluginListenerHandle>` | Register listener for events; returns handle (release with `handle.remove()`) |
|
|
53
|
+
| `removeAllListeners` | `() => Promise<void>` | Remove all event listeners |
|
|
54
|
+
|
|
55
|
+
## Usage Examples
|
|
56
|
+
|
|
57
|
+
### Subscribe to broadcasts
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
61
|
+
|
|
62
|
+
const unsub = await Broadcast.subscribe(
|
|
63
|
+
["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
64
|
+
(result) => {
|
|
65
|
+
// handle result.action, result.extras
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// Unsubscribe
|
|
70
|
+
await unsub();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Send a broadcast
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
77
|
+
|
|
78
|
+
await Broadcast.send({
|
|
79
|
+
action: "com.symbol.datawedge.api.ACTION",
|
|
80
|
+
extras: {
|
|
81
|
+
"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
```
|