@simplysm/capacitor-plugin-broadcast 13.0.72 → 13.0.75

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 +128 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,21 +2,140 @@
2
2
 
3
3
  Simplysm Package - Capacitor Broadcast Plugin
4
4
 
5
+ A Capacitor plugin for sending and receiving Android broadcasts. Designed for industrial device integration (barcode scanners, PDAs, etc.).
6
+
5
7
  ## Installation
6
8
 
9
+ ```bash
7
10
  pnpm add @simplysm/capacitor-plugin-broadcast
11
+ ```
8
12
 
9
- **Peer Dependencies:** `@capacitor/core ^7.4.4`
10
-
11
- ## Source Index
13
+ ## Main Modules
12
14
 
13
15
  ### Broadcast
14
16
 
15
- | Source | Exports | Description | Test |
16
- |--------|---------|-------------|------|
17
- | `src/Broadcast.ts` | `Broadcast` | Static class to send, subscribe, and listen to Android broadcast intents | - |
18
- | `src/IBroadcastPlugin.ts` | `IBroadcastResult`, `IBroadcastPlugin` | Interfaces for broadcast result data and the native broadcast plugin contract | - |
17
+ A static class for sending and receiving Android broadcasts.
18
+
19
+ #### `Broadcast.subscribe(filters, callback)`
20
+
21
+ Registers a broadcast receiver for the given action filters. Returns an async unsubscribe function.
22
+
23
+ ```ts
24
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
25
+
26
+ const unsub = await Broadcast.subscribe(
27
+ ["com.symbol.datawedge.api.RESULT_ACTION"],
28
+ (result) => {
29
+ console.log(result.action);
30
+ console.log(result.extras);
31
+ }
32
+ );
33
+
34
+ // Unsubscribe when done
35
+ await unsub();
36
+ ```
37
+
38
+ | Parameter | Type | Description |
39
+ | ---------- | --------------------------------------- | ---------------------------------------- |
40
+ | `filters` | `string[]` | List of broadcast action strings to listen for |
41
+ | `callback` | `(result: IBroadcastResult) => void` | Called each time a matching broadcast is received |
42
+
43
+ Returns: `Promise<() => Promise<void>>` — an async function that unsubscribes the receiver.
44
+
45
+ #### `Broadcast.unsubscribeAll()`
46
+
47
+ Unsubscribes all currently registered broadcast receivers.
48
+
49
+ ```ts
50
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
51
+
52
+ await Broadcast.unsubscribeAll();
53
+ ```
54
+
55
+ #### `Broadcast.send(options)`
56
+
57
+ Sends an Android broadcast intent.
58
+
59
+ ```ts
60
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
61
+
62
+ await Broadcast.send({
63
+ action: "com.symbol.datawedge.api.ACTION",
64
+ extras: {
65
+ "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER": "TOGGLE_SCANNING",
66
+ },
67
+ });
68
+ ```
69
+
70
+ | Parameter | Type | Description |
71
+ | ---------------- | ----------------------------- | ----------------------------------- |
72
+ | `options.action` | `string` | The broadcast action string to send |
73
+ | `options.extras` | `Record<string, unknown>` (optional) | Extra data to include in the intent |
74
+
75
+ #### `Broadcast.getLaunchIntent()`
76
+
77
+ Returns the intent that launched the app, if available.
78
+
79
+ ```ts
80
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
81
+
82
+ const intent = await Broadcast.getLaunchIntent();
83
+ console.log(intent.action);
84
+ console.log(intent.extras);
85
+ ```
86
+
87
+ Returns: `Promise<IBroadcastResult>`
88
+
89
+ #### `Broadcast.addNewIntentListener(callback)`
90
+
91
+ Registers a listener for new intents received while the app is running. Returns a `PluginListenerHandle` which can be released by calling `.remove()`.
92
+
93
+ ```ts
94
+ import { Broadcast } from "@simplysm/capacitor-plugin-broadcast";
95
+
96
+ const handle = await Broadcast.addNewIntentListener((result) => {
97
+ console.log(result.action);
98
+ console.log(result.extras);
99
+ });
100
+
101
+ // Remove listener when done
102
+ await handle.remove();
103
+ ```
104
+
105
+ | Parameter | Type | Description |
106
+ | ---------- | --------------------------------------- | ---------------------------------------- |
107
+ | `callback` | `(result: IBroadcastResult) => void` | Called when a new intent is received |
108
+
109
+ Returns: `Promise<PluginListenerHandle>`
110
+
111
+ ## Types
112
+
113
+ ### `IBroadcastResult`
114
+
115
+ Represents the data received from a broadcast intent.
116
+
117
+ ```ts
118
+ import type { IBroadcastResult } from "@simplysm/capacitor-plugin-broadcast";
119
+ ```
120
+
121
+ | Field | Type | Description |
122
+ | --------- | ----------------------------- | --------------------- |
123
+ | `action` | `string` (optional) | The broadcast action |
124
+ | `extras` | `Record<string, unknown>` (optional) | Extra intent data |
125
+
126
+ ### `IBroadcastPlugin`
127
+
128
+ The low-level Capacitor plugin interface. Use the `Broadcast` class instead of this interface directly.
19
129
 
20
- ## License
130
+ ```ts
131
+ import type { IBroadcastPlugin } from "@simplysm/capacitor-plugin-broadcast";
132
+ ```
21
133
 
22
- Apache-2.0
134
+ | Method | Signature | Description |
135
+ | ------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------- |
136
+ | `subscribe` | `(options: { filters: string[] }, callback: (result: IBroadcastResult) => void) => Promise<{ id: string }>` | Register a broadcast receiver |
137
+ | `unsubscribe` | `(options: { id: string }) => Promise<void>` | Unsubscribe a specific receiver by ID |
138
+ | `unsubscribeAll` | `() => Promise<void>` | Unsubscribe all receivers |
139
+ | `send` | `(options: { action: string; extras?: Record<string, unknown> }) => Promise<void>` | Send a broadcast |
140
+ | `getLaunchIntent` | `() => Promise<IBroadcastResult>` | Get the launch intent |
141
+ | `addListener` | `(eventName: "onNewIntent", listenerFunc: (data: IBroadcastResult) => void) => Promise<PluginListenerHandle>` | Listen for new intents while app is running |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-broadcast",
3
- "version": "13.0.72",
3
+ "version": "13.0.75",
4
4
  "description": "Simplysm Package - Capacitor Broadcast Plugin",
5
5
  "author": "simplysm",
6
6
  "license": "MIT",