@ruhiverse/thermal-printer-plugin 1.0.4 → 1.0.5

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.
@@ -208,37 +208,38 @@ public class ThermalPrinterPlugin: CAPPlugin, CBCentralManagerDelegate, CBPeriph
208
208
  }
209
209
 
210
210
  // Find peripheral by identifier
211
- if let uuid = UUID(uuidString: address),
212
- let peripherals = centralManager.retrievePeripherals(withIdentifiers: [uuid]),
213
- let peripheral = peripherals.first {
214
- // Found in known peripherals, connect directly
215
- printData = data
216
- printCompletion = { success, error in
217
- if success {
218
- DispatchQueue.main.async {
219
- call.resolve([
220
- "success": true,
221
- "message": "Bluetooth print data sent to printer (BLE).",
222
- ])
211
+ if let uuid = UUID(uuidString: address) {
212
+ let peripherals = centralManager.retrievePeripherals(withIdentifiers: [uuid])
213
+ if let peripheral = peripherals.first {
214
+ // Found in known peripherals, connect directly
215
+ printData = data
216
+ printCompletion = { success, error in
217
+ if success {
218
+ DispatchQueue.main.async {
219
+ call.resolve([
220
+ "success": true,
221
+ "message": "Bluetooth print data sent to printer (BLE).",
222
+ ])
223
+ }
224
+ } else {
225
+ DispatchQueue.main.async {
226
+ call.reject("BLE print failed: \(error ?? "Unknown error")")
227
+ }
223
228
  }
229
+ }
230
+
231
+ connectedPeripheral = peripheral
232
+ peripheral.delegate = self
233
+
234
+ if centralManager.state == .poweredOn {
235
+ centralManager.connect(peripheral, options: nil)
224
236
  } else {
225
237
  DispatchQueue.main.async {
226
- call.reject("BLE print failed: \(error ?? "Unknown error")")
238
+ call.reject("Bluetooth is not powered on")
227
239
  }
228
240
  }
241
+ return
229
242
  }
230
-
231
- connectedPeripheral = peripheral
232
- peripheral.delegate = self
233
-
234
- if centralManager.state == .poweredOn {
235
- centralManager.connect(peripheral, options: nil)
236
- } else {
237
- DispatchQueue.main.async {
238
- call.reject("Bluetooth is not powered on")
239
- }
240
- }
241
- return
242
243
  }
243
244
 
244
245
  // Not found in known peripherals, scan for it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruhiverse/thermal-printer-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Capacitor plugin for thermal printing via USB and Bluetooth",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",