@simplysm/capacitor-plugin-broadcast 13.0.98 → 13.0.100
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 +35 -84
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @simplysm/capacitor-plugin-broadcast
|
|
2
2
|
|
|
3
|
-
Capacitor Broadcast Plugin
|
|
3
|
+
Simplysm Package - Capacitor Broadcast Plugin. Provides Android Broadcast send/receive functionality for industrial device integration (barcode scanners, PDAs, etc.).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,83 +10,47 @@ npm install @simplysm/capacitor-plugin-broadcast
|
|
|
10
10
|
|
|
11
11
|
## API Overview
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Broadcast
|
|
14
14
|
|
|
15
15
|
| API | Type | Description |
|
|
16
16
|
|-----|------|-------------|
|
|
17
|
-
| `
|
|
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 |
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
---
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|-----|------|-------------|
|
|
23
|
-
| `BroadcastPlugin` | interface | Low-level Capacitor plugin interface for broadcast operations |
|
|
24
|
-
|
|
25
|
-
### Classes
|
|
26
|
-
|
|
27
|
-
| API | Type | Description |
|
|
28
|
-
|-----|------|-------------|
|
|
29
|
-
| `Broadcast` | abstract class | Android broadcast send/receive operations |
|
|
30
|
-
|
|
31
|
-
## `BroadcastResult`
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
interface BroadcastResult {
|
|
35
|
-
/** Broadcast action */
|
|
36
|
-
action?: string;
|
|
37
|
-
/** Extra data */
|
|
38
|
-
extras?: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## `BroadcastPlugin`
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
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
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Low-level Capacitor plugin interface. Use `Broadcast` static methods instead of calling this directly.
|
|
23
|
+
### `BroadcastResult`
|
|
63
24
|
|
|
64
|
-
|
|
25
|
+
| Field | Type | Description |
|
|
26
|
+
|-------|------|-------------|
|
|
27
|
+
| `action` | `string \| undefined` | Broadcast action |
|
|
28
|
+
| `extras` | `Record<string, unknown> \| undefined` | Extra data |
|
|
65
29
|
|
|
66
|
-
|
|
67
|
-
abstract class Broadcast {
|
|
68
|
-
static async subscribe(
|
|
69
|
-
filters: string[],
|
|
70
|
-
callback: (result: BroadcastResult) => void,
|
|
71
|
-
): Promise<() => Promise<void>>;
|
|
30
|
+
### `BroadcastPlugin`
|
|
72
31
|
|
|
73
|
-
|
|
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 |
|
|
74
41
|
|
|
75
|
-
|
|
76
|
-
action: string;
|
|
77
|
-
extras?: Record<string, unknown>;
|
|
78
|
-
}): Promise<void>;
|
|
42
|
+
### `Broadcast`
|
|
79
43
|
|
|
80
|
-
|
|
44
|
+
Abstract class with static methods for Android Broadcast send/receive.
|
|
81
45
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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 |
|
|
90
54
|
|
|
91
55
|
## Usage Examples
|
|
92
56
|
|
|
@@ -99,10 +63,10 @@ const unsub = await Broadcast.subscribe(
|
|
|
99
63
|
["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
100
64
|
(result) => {
|
|
101
65
|
// handle result.action, result.extras
|
|
102
|
-
}
|
|
66
|
+
}
|
|
103
67
|
);
|
|
104
68
|
|
|
105
|
-
//
|
|
69
|
+
// Unsubscribe
|
|
106
70
|
await unsub();
|
|
107
71
|
```
|
|
108
72
|
|
|
@@ -114,20 +78,7 @@ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
|
114
78
|
await Broadcast.send({
|
|
115
79
|
action: "com.symbol.datawedge.api.ACTION",
|
|
116
80
|
extras: {
|
|
117
|
-
"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
118
|
-
}
|
|
81
|
+
"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING"
|
|
82
|
+
}
|
|
119
83
|
});
|
|
120
84
|
```
|
|
121
|
-
|
|
122
|
-
### Listen for new intents
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
126
|
-
|
|
127
|
-
const handle = await Broadcast.addListener("newIntent", (result) => {
|
|
128
|
-
// handle intent
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Later: remove listener
|
|
132
|
-
await handle.remove();
|
|
133
|
-
```
|