LCOV - code coverage report
Current view: top level - src - beacon.manager.ts (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 35 0.0 %
Date: 2019-12-04 11:32:04 Functions: 0 29 0.0 %

          Line data    Source code
       1             : // @flow
       2             : 
       3             : import {
       4             :     NativeModules,
       5             :     NativeEventEmitter,
       6             :     EmitterSubscription // eslint-disable-line no-unused-vars
       7             : } from 'react-native';
       8           0 : const BeaconManager = NativeModules.CBBeacon;
       9           0 : const EventEmitter = new NativeEventEmitter(BeaconManager);
      10             : 
      11             : /* eslint-disable */
      12             : import {
      13             :     AuthorizationStatus,
      14             :     BluetoothState,
      15             :     Region,
      16             :     AuthorizationStatusCallback,
      17             :     DidRangeBeaconsCallback,
      18             :     DidEnterRegionCallback,
      19             :     DidExitRegionCallback,
      20             :     DidDetermineStateForRegionCallback,
      21             : } from './beacon.types';
      22             : /* eslint-enable */
      23             : 
      24           0 : const sampleMethod = function (str: string, num: number, callback: (result: String) => void) {
      25           0 :     BeaconManager.sampleMethod(str, num, callback);
      26             : }
      27             : 
      28           0 : const initialize = function () {
      29           0 :     BeaconManager.setup();
      30             : }
      31             : 
      32           0 : const dispose = function () {
      33           0 :     BeaconManager.close();
      34             : }
      35             : 
      36           0 : const openApplicationSettings = function () {
      37           0 :     BeaconManager.openApplicationSettings();
      38             : }
      39             : 
      40             : class BluetoothService {
      41             :     static checkBluetoothState(callback: (status: BluetoothState) => void) {
      42           0 :         BeaconManager.bluetoothEnabled(callback);
      43             :     }
      44             : 
      45             :     static openBluetoothSettings() {
      46           0 :         BeaconManager.openBluetoothSettings();
      47             :     }
      48             : }
      49             : 
      50             : class LocationService {
      51             :     static openLocationSettings() {
      52           0 :         BeaconManager.openLocationSettings();
      53             :     }
      54             : 
      55             :     static checkIfEnabled(callback: (enabled: boolean) => void) {
      56           0 :         BeaconManager.locationServicesEnabled(callback);
      57             :     }
      58             : }
      59             : 
      60             : class Authorization {
      61             :     static checkAuthorizationStatus(callback: (status: AuthorizationStatus) => void) {
      62           0 :         BeaconManager.authorizationStatus(callback);
      63             :     }
      64             : 
      65             :     static requestAlwaysAuthorization() {
      66           0 :         BeaconManager.requestAlwaysAuthorization();
      67             :     }
      68             :     
      69             :     static requestWhenInUseAuthorization() {
      70           0 :         BeaconManager.requestWhenInUseAuthorization();
      71             :     }
      72             : }
      73             : 
      74             : class Monitoring {
      75             :     static startMonitoringForRegion(region: Region) {
      76           0 :         BeaconManager.startMonitoringForRegion(region);
      77             :     }
      78             :     
      79             :     static startMonitoringForRegions(regions: Array < Region > ) {
      80           0 :         BeaconManager.startMonitoringForRegions(regions);
      81             :     }
      82             :     
      83             :     static stopMonitoringForRegion(region: Region) {
      84           0 :         BeaconManager.stopMonitoringForRegion(region);
      85             :     }
      86             : }
      87             : 
      88             : class Ranging {
      89             :     static startRangingBeaconsInRegion(region: Region) {
      90           0 :         BeaconManager.startRangingBeaconsInRegion(region);
      91             :     }
      92             :     
      93             :     static startRangingBeaconsInRegions(regions: Array < Region > ) {
      94           0 :         BeaconManager.startRangingBeaconsInRegions(regions);
      95             :     }
      96             :     
      97             :     static stopRangingBeaconsInRegion(region: Region) {
      98           0 :         BeaconManager.stopRangingBeaconsInRegion(region);
      99             :     }
     100             : }
     101             : 
     102             : class Listener {
     103             :     static didRangeBeacons(callback: DidRangeBeaconsCallback): EmitterSubscription {
     104           0 :         return EventEmitter.addListener(
     105             :             'didRangeBeacons',
     106           0 :             (data) => callback(data.region, data.beacons),
     107             :         );
     108             :     }
     109             : 
     110             :     static didDetermineStateForRegion(callback: DidDetermineStateForRegionCallback): EmitterSubscription {
     111           0 :         return EventEmitter.addListener(
     112             :             'didDetermineStateForRegion',
     113           0 :             (data) => callback(data.region, data.state),
     114             :         );
     115             :     }
     116             : 
     117             :     static didEnterRegion(callback: DidEnterRegionCallback): EmitterSubscription {
     118           0 :         return EventEmitter.addListener(
     119             :             'didEnterRegion',
     120           0 :             (data) => callback(data.region),
     121             :         );
     122             :     }
     123             :     
     124             :     static didExitRegion(callback: DidExitRegionCallback): EmitterSubscription {
     125           0 :         return EventEmitter.addListener(
     126             :             'didExitRegion',
     127           0 :             (data) => callback(data.region),
     128             :         );
     129             :     }
     130             : 
     131             :     static didChangeAuthorizationStatus(callback: AuthorizationStatusCallback): EmitterSubscription {
     132           0 :         return EventEmitter.addListener(
     133             :             'didChangeAuthorizationStatus',
     134           0 :             data => callback(data),
     135             :         );
     136             :     }
     137             : 
     138             :     static bluetoothDidUpdateState(callback: (state: BluetoothState) => any): EmitterSubscription {
     139           0 :         return EventEmitter.addListener(
     140             :             'bluetoothDidUpdateState',
     141             :             callback,
     142             :         );
     143             :     }
     144             :     
     145             :     static onBeaconServiceConnect(callback: () => void): EmitterSubscription {
     146           0 :         return EventEmitter.addListener(
     147             :             'onBeaconServiceConnect',
     148             :             callback,
     149             :         );
     150             :     }
     151             : }
     152             : 
     153             : export default {
     154             :     sampleMethod,
     155             :     initialize,
     156             :     dispose,
     157             : 
     158             :     openApplicationSettings,
     159             :     
     160             :     BluetoothService,
     161             :     LocationService,
     162             :     Authorization,
     163             :     Listener,
     164             :     Monitoring,
     165             :     Ranging,
     166             : };

Generated by: LCOV version 1.14