The options object passed into the startScanning function.

interface StartScanningOptions {
    android?: {
        callbackType?: CallbackType;
        legacy?: boolean;
        matchMode?: MatchMode;
        matchNum?: MatchNum;
        phy?: Phy;
        reportDelay?: number;
        scanMode?: ScanMode;
        useHardwareBatchingIfSupported?: boolean;
    };
    avoidDuplicates?: boolean;
    filters?: {
        deviceAddress?: string;
        deviceName?: string;
        manufacturerData?: ArrayBuffer;
        serviceUUID?: string;
    }[];
    onDiscovered?: (data: Peripheral) => void;
    seconds?: number;
    skipPermissionCheck?: boolean;
}

Properties

android?: {
    callbackType?: CallbackType;
    legacy?: boolean;
    matchMode?: MatchMode;
    matchNum?: MatchNum;
    phy?: Phy;
    reportDelay?: number;
    scanMode?: ScanMode;
    useHardwareBatchingIfSupported?: boolean;
}

Android scanning specific options. The defaults should cover majority of use cases. Be sure to check documentation for the various values for Android Bluetooth.

Type declaration

  • OptionalcallbackType?: CallbackType

    *** Only available on Android 23+ *** The callback type flags for the scan. TODO: Add documentation on the valid values for callbackTypes.

  • Optionallegacy?: boolean

    Set whether only legacy advertisements should be returned in scan results. Legacy advertisements include advertisements as specified by the Bluetooth core specification 4.2 and below. This is true by default for compatibility with older apps.

    true if only legacy advertisements will be returned

  • OptionalmatchMode?: MatchMode

    *** Only available on Android 23+ *** The match mode can be one of android.bluetooth.le.ScanSettings.MATCH_MODE_AGGRESSIVE (1) or android.bluetooth.le.ScanSettings.MATCH_MODE_STICKY (2) DEFAULT: MATCH_MODE_AGGRESSIVE (2).

  • OptionalmatchNum?: MatchNum

    *** Only available on Android 23+ *** The num of matches can be one of android.bluetooth.le.ScanSettings.MATCH_NUM_ONE_ADVERTISEMENT (1), android.bluetooth.le.ScanSettings.MATCH_NUM_FEW_ADVERTISEMENT (2), or android.bluetooth.le.ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT (3) DEFAULT: MATCH_NUM_MAX_ADVERTISEMENT(3)

  • Optionalphy?: Phy

    *** Only available on Android 23+ *** Set the Physical Layer to use during this scan. This is used only if ScanSettings.Builder#setLegacy is set to false and only on Android 0reo or newer. android.bluetooth.BluetoothAdapter#isLeCodedPhySupported may be used to check whether LE Coded phy is supported by calling android.bluetooth.BluetoothAdapter#isLeCodedPhySupported. Selecting an unsupported phy will result in failure to start scan.

    Can be one of BluetoothDevice#PHY_LE_1M, BluetoothDevice#PHY_LE_CODED or ScanSettings#PHY_LE_ALL_SUPPORTED

  • OptionalreportDelay?: number

    Set report delay timestamp for Bluetooth LE scan.

    Delay of report in milliseconds. Set to 0 to be notified of results immediately. Values > 0 causes the scan results to be queued up and delivered after the requested delay or when the internal buffers fill up.

    IllegalArgumentException If {@code reportDelayMillis} < 0.

  • OptionalscanMode?: ScanMode

    *** Only available on Android 21+ *** The scan mode can be one of android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_POWER (0), android.bluetooth.le.ScanSettings.SCAN_MODE_BALANCED (1) , or android.bluetooth.le.ScanSettings.SCAN_MODE_LOW_LATENCY (2). DEFAULT: SCAN_MODE_LOW_LATENCY (2)

  • OptionaluseHardwareBatchingIfSupported?: boolean

    Several phones may have some issues when it comes to offloaded filtering. Even if it should be supported, it may not work as expected. It has been observed for example, that setting 2 filters with different devices addresses on Nexus 6 with Lollipop gives no callbacks if one or both devices advertise. See https://code.google.com/p/android/issues/detail?id=181561.

    true to enable (default) hardware offload filtering. If false a compat software filtering will be used (uses much more resources).

avoidDuplicates?: boolean

Avoid duplicates with the same serviceUUID in "onDiscovered" callback. If true, only the first discovered peripheral with the same serviceUUID will be reported.

filters?: {
    deviceAddress?: string;
    deviceName?: string;
    manufacturerData?: ArrayBuffer;
    serviceUUID?: string;
}[]

Zero or more services which the peripheral needs to broadcast. Default: [], which matches any peripheral.

onDiscovered?: (data: Peripheral) => void

This callback is invoked when a peripheral is found.

seconds?: number

The number of seconds to scan for services. Default: unlimited, which is not really recommended. You should stop scanning manually by calling 'stopScanning'.

skipPermissionCheck?: boolean

*** ANDROID ONLY *** Set this to true if you don't want the plugin to check (and request) the required Bluetooth permissions. Particularly useful if you're running this function on a non-UI thread (ie. a Worker).