@@ -2,7 +2,7 @@ import { Injectable, NgZone } from '@angular/core';
22import { Observable , Subscription , fromEventPattern } from 'rxjs' ;
33import { takeWhile } from 'rxjs/operators' ;
44import * as dialogs from '@nativescript/core/ui/dialogs' ;
5- import { Bluetooth , Peripheral , Service , Characteristic , ReadResult } from '@nativescript-community/ble' ;
5+ import { Bluetooth , Characteristic , Peripheral , ReadResult , Service } from '@nativescript-community/ble' ;
66
77const bluetooth = new Bluetooth ( ) ;
88bluetooth . debug = true ;
@@ -85,7 +85,7 @@ export class BluetoothService {
8585 console . log ( 'Creating BluetoothService' ) ;
8686 }
8787
88- public peripheralList : Array < IPeripheral > = [ ] ; // public storage for the list of last-scanned peripherals
88+ public peripheralList : IPeripheral [ ] = [ ] ; // public storage for the list of last-scanned peripherals
8989 public isScanning = false ;
9090
9191 private isBluetoothEnabled : boolean ;
@@ -215,9 +215,9 @@ export class BluetoothService {
215215 console . log ( `scanForPeripherals(${ JSON . stringify ( serviceUUIDs ) } , ${ seconds } ) called` ) ;
216216
217217 // Android 6 needs this permission to scan for peripherals in the background.
218- bluetooth . hasCoarseLocationPermission ( ) . then ( granted => {
218+ bluetooth . hasLocationPermission ( ) . then ( granted => {
219219 if ( ! granted ) {
220- bluetooth . requestCoarseLocationPermission ( ) ;
220+ bluetooth . requestLocationPermission ( ) ;
221221 return false ;
222222 }
223223 } ) ;
@@ -227,9 +227,7 @@ export class BluetoothService {
227227 this . scanSubscription = this . startScan ( serviceUUIDs , seconds )
228228 . pipe (
229229 takeWhile (
230- ( peripheral : IPeripheral , idx : number ) : boolean => {
231- return peripheral . UUID !== BluetoothService . SIGNAL_STOP_PERIPHERAL ( ) . UUID ;
232- }
230+ ( peripheral : IPeripheral , idx : number ) : boolean => peripheral . UUID !== BluetoothService . SIGNAL_STOP_PERIPHERAL ( ) . UUID
233231 )
234232 )
235233 . subscribe (
@@ -259,7 +257,7 @@ export class BluetoothService {
259257 bluetooth
260258 . startScanning ( {
261259 filters,
262- seconds : seconds ,
260+ seconds,
263261 onDiscovered : ( peripheral : IPeripheral ) => handler ( peripheral ) ,
264262 skipPermissionCheck : false
265263 } )
@@ -380,7 +378,7 @@ export class BluetoothService {
380378 peripheralUUID : characteristic . serviceRef . peripheralRef . UUID ,
381379 serviceUUID : characteristic . serviceRef . UUID ,
382380 characteristicUUID : characteristic . UUID ,
383- value : value
381+ value
384382 } )
385383 . then (
386384 res => {
@@ -425,7 +423,7 @@ export class BluetoothService {
425423 peripheralUUID : characteristic . serviceRef . peripheralRef . UUID ,
426424 serviceUUID : characteristic . serviceRef . UUID ,
427425 characteristicUUID : characteristic . UUID ,
428- value : value
426+ value
429427 } )
430428 . then (
431429 res => {
0 commit comments