3.2.1 • Published 26 days ago

capacitor-nearby v3.2.1

Weekly downloads
22
License
MIT
Repository
github
Last release
26 days ago

@capacitor-community/capacitor-nearby

Uses Bluetooth LE to scan and advertise for nearby devices

Install

npm install @capacitor-community/capacitor-nearby
npx cap sync

API

initialize(...)

initialize(options: InitializeOptions) => Promise<void>

Initializes Bluetooth LE for advertising and scanning of nearby tokens.

ParamType
optionsInitializeOptions

Since: 1.0.0


reset()

reset() => Promise<void>

Stops and resets advertising and scanning of nearby tokens.

Since: 1.0.0


publish(...)

publish(options: PublishOptions) => Promise<void>

Start publishing nearby token.

ParamType
optionsPublishOptions

Since: 1.0.0


unpublish()

unpublish() => Promise<void>

Stop publishing nearby token.

Since: 1.0.0


subscribe(...)

subscribe(options: SubscribeOptions) => Promise<void>

Start listening to nearby tokens.

ParamType
optionsSubscribeOptions

Since: 1.0.0


unsubscribe()

unsubscribe() => Promise<void>

Stop listening to nearby tokens.

Since: 1.0.0


status()

status() => Promise<Status>

Returns status of operations and found tokens.

Returns: Promise<Status>

Since: 1.0.0


addListener('onPermissionChanged', ...)

addListener(eventName: 'onPermissionChanged', listenerFunc: (granted: boolean) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when permission is granted or revoked for this app to use Nearby.

ParamType
eventName'onPermissionChanged'
listenerFunc(granted: boolean) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('onBluetoothStateChanged', ...)

addListener(eventName: 'onBluetoothStateChanged', listenerFunc: (state: BluetoothState) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when state of Bluetooth has changed.

ParamType
eventName'onBluetoothStateChanged'
listenerFunc(state: BluetoothState) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('onFound', ...)

addListener(eventName: 'onFound', listenerFunc: BeaconCallback) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when beacons are found.

ParamType
eventName'onFound'
listenerFuncBeaconCallback

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.1.0


addListener('onLost', ...)

addListener(eventName: 'onLost', listenerFunc: BeaconCallback) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when a beacon is no longer detectable nearby.

ParamType
eventName'onLost'
listenerFuncBeaconCallback

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.1.0


addListener('onPublishExpired', ...)

addListener(eventName: 'onPublishExpired', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle

The published token has expired.

ParamType
eventName'onPublishExpired'
listenerFunc() => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('onSubscribeExpired', ...)

addListener(eventName: 'onSubscribeExpired', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle

The subscription has expired.

ParamType
eventName'onSubscribeExpired'
listenerFunc() => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


Interfaces

InitializeOptions

PropTypeDescriptionDefaultSince
serviceUUIDUUIDSets the service UUID for the nearby token.1.0.0
scanModeScanModeSets the scan mode. Default: Perform Bluetooth LE scan in balanced power mode.ScanMode.BALANCED1.0.0
advertiseModeAdvertiseModeSets the advertise mode. Default: Perform Bluetooth LE advertising in low latency, high power mode.AdvertiseMode.LOW_LATENCY1.0.0
txPowerLevelTxPowerLevelSets the TX power level for advertising. Default: Advertise using high TX power level.TxPowerLevel.HIGH1.0.0

PublishOptions

PropTypeDescriptionSince
uuidUUIDSets the beacon UUID for the publish operation.1.1.0
ttlSecondsTTLSecondsSets the time to live in seconds for the publish operation.1.0.0

SubscribeOptions

PropTypeDescriptionSince
ttlSecondsTTLSecondsSets the time to live in seconds for the subscribe operation.1.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

Type Aliases

UUID

string

Status

{ isPublishing: boolean; isSubscribing: boolean; uuids: UUID[]; }

BeaconCallback

(uuid: string, rssi?: string | number): void

Enums

ScanMode

MembersValue
LOW_POWER0
BALANCED1
LOW_LATENCY2
OPPORTUNISTIC-1

AdvertiseMode

MembersValue
LOW_POWER0
BALANCED1
LOW_LATENCY2

TxPowerLevel

MembersValue
ULTRA_LOW0
LOW1
MEDIUM2
HIGH3

TTLSeconds

MembersValue
TTL_SECONDS_DEFAULT300
TTL_SECONDS_MAX86400
TTL_SECONDS_INFINITE2147483647

BluetoothState

MembersValue
UNKNOWN'unknown'
RESETTING'resetting'
UNSUPPORTED'unsupported'
UNAUTHORIZED'unauthorized'
POWERED_OFF'poweredOff'
POWERED_ON'poweredOn'
3.2.1

26 days ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago

0.4.5

3 years ago

0.4.6

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago