@simplysm/capacitor-plugin-broadcast 12.16.30 → 12.16.35
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 +121 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @simplysm/capacitor-plugin-broadcast
|
|
2
|
+
|
|
3
|
+
Capacitor Broadcast Plugin -- Android broadcast send/receive for industrial devices (barcode scanners, PDA, etc.). Provides subscription-based broadcast receiving, broadcast sending with extras, and launch intent retrieval.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @simplysm/capacitor-plugin-broadcast
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Overview
|
|
12
|
+
|
|
13
|
+
| API | Type | Description |
|
|
14
|
+
|-----|------|-------------|
|
|
15
|
+
| `Broadcast` | Abstract class | Static methods for subscribing to, sending, and managing Android broadcasts |
|
|
16
|
+
| `IBroadcastResult` | Interface | Broadcast result containing action and extras |
|
|
17
|
+
| `IBroadcastPlugin` | Interface | Low-level Capacitor plugin interface for broadcast operations |
|
|
18
|
+
|
|
19
|
+
## API Reference
|
|
20
|
+
|
|
21
|
+
### `IBroadcastResult`
|
|
22
|
+
|
|
23
|
+
Result object received from a broadcast or launch intent.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
export interface IBroadcastResult {
|
|
27
|
+
action?: string;
|
|
28
|
+
extras?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Field | Type | Description |
|
|
33
|
+
|-------|------|-------------|
|
|
34
|
+
| `action` | `string \| undefined` | The broadcast action string |
|
|
35
|
+
| `extras` | `Record<string, unknown> \| undefined` | Extra data attached to the broadcast |
|
|
36
|
+
|
|
37
|
+
### `IBroadcastPlugin`
|
|
38
|
+
|
|
39
|
+
Low-level Capacitor plugin interface. Use `Broadcast` instead for a simplified API.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
export interface IBroadcastPlugin {
|
|
43
|
+
subscribe(
|
|
44
|
+
options: { filters: string[] },
|
|
45
|
+
callback: (result: IBroadcastResult) => void,
|
|
46
|
+
): Promise<{ id: string }>;
|
|
47
|
+
unsubscribe(options: { id: string }): Promise<void>;
|
|
48
|
+
unsubscribeAll(): Promise<void>;
|
|
49
|
+
send(options: { action: string; extras?: Record<string, unknown> }): Promise<void>;
|
|
50
|
+
getLaunchIntent(): Promise<IBroadcastResult>;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Method | Parameters | Returns | Description |
|
|
55
|
+
|--------|------------|---------|-------------|
|
|
56
|
+
| `subscribe` | `options: { filters: string[] }, callback` | `Promise<{ id: string }>` | Register a broadcast receiver with action filters |
|
|
57
|
+
| `unsubscribe` | `options: { id: string }` | `Promise<void>` | Remove a specific broadcast receiver by ID |
|
|
58
|
+
| `unsubscribeAll` | -- | `Promise<void>` | Remove all broadcast receivers |
|
|
59
|
+
| `send` | `options: { action, extras? }` | `Promise<void>` | Send a broadcast with action and optional extras |
|
|
60
|
+
| `getLaunchIntent` | -- | `Promise<IBroadcastResult>` | Get the intent that launched the app |
|
|
61
|
+
|
|
62
|
+
### `Broadcast`
|
|
63
|
+
|
|
64
|
+
Abstract class with static methods for Android broadcast send/receive. Designed for industrial device integration (barcode scanners, PDA, etc.).
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
export abstract class Broadcast {
|
|
68
|
+
static async subscribe(
|
|
69
|
+
filters: string[],
|
|
70
|
+
callback: (result: IBroadcastResult) => 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<IBroadcastResult>;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
| Method | Parameters | Returns | Description |
|
|
85
|
+
|--------|------------|---------|-------------|
|
|
86
|
+
| `subscribe` | `filters: string[], callback: (result: IBroadcastResult) => void` | `Promise<() => Promise<void>>` | Register a broadcast receiver; returns an unsubscribe function |
|
|
87
|
+
| `unsubscribeAll` | -- | `Promise<void>` | Remove all registered broadcast receivers |
|
|
88
|
+
| `send` | `options: { action: string; extras?: Record<string, unknown> }` | `Promise<void>` | Send a broadcast with action and optional extras |
|
|
89
|
+
| `getLaunchIntent` | -- | `Promise<IBroadcastResult>` | Retrieve the intent that launched the application |
|
|
90
|
+
|
|
91
|
+
## Usage Examples
|
|
92
|
+
|
|
93
|
+
### Subscribe to broadcasts from a barcode scanner
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
97
|
+
|
|
98
|
+
const unsubscribe = await Broadcast.subscribe(
|
|
99
|
+
["com.symbol.datawedge.api.RESULT_ACTION"],
|
|
100
|
+
(result) => {
|
|
101
|
+
console.log("Action:", result.action);
|
|
102
|
+
console.log("Extras:", result.extras);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Later, unsubscribe
|
|
107
|
+
await unsubscribe();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Send a broadcast to trigger a scan
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
|
|
114
|
+
|
|
115
|
+
await Broadcast.send({
|
|
116
|
+
action: "com.symbol.datawedge.api.ACTION",
|
|
117
|
+
extras: {
|
|
118
|
+
"com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/capacitor-plugin-broadcast",
|
|
3
|
-
"version": "12.16.
|
|
3
|
+
"version": "12.16.35",
|
|
4
4
|
"description": "심플리즘 패키지 - Capacitor Broadcast Plugin",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"@capacitor/core": "^7.4.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@capacitor/core": "^7.
|
|
24
|
+
"@capacitor/core": "^7.6.0"
|
|
25
25
|
}
|
|
26
26
|
}
|