@capacitor-trancee/bridgefy
v1.2.1
Published
Bridgefy creates mesh networks in which devices connect directly to each other in a decentralized manner. This allows users to communicate with nearby devices within a certain range, forming a network without the need for a centralized server or Internet
Readme
@capacitor-trancee/bridgefy
Bridgefy creates mesh networks in which devices connect directly to each other in a decentralized manner. This allows users to communicate with nearby devices within a certain range, forming a network without the need for a centralized server or Internet access.
Install
npm install @capacitor-trancee/bridgefy
npx cap syncExample
Import type definitions
import { Bridgefy, PermissionType, PropagationProfile, TransmissionType, UUID } from "@capacitor-trancee/bridgefy"Set up event listeners
await Bridgefy.addListener( "onStarted", (event) => { console.info("Bridgefy::onStarted", event) }) await Bridgefy.addListener( "onStopped", (event) => { console.info("Bridgefy::onStopped", event) })Check and request permissions
let permissionStatus = await Bridgefy.checkPermissions() console.info("Bridgefy.checkPermissions", permissionStatus) const permissions: PermissionType[] = [] if (permissionStatus.bluetooth === "prompt") { permissions.push("bluetooth") } if (permissionStatus.location === "prompt") { permissions.push("location") } if (permissions.length > 0) { permissionStatus = await Bridgefy.requestPermissions({ permissions: permissions, }) console.info("Bridgefy.requestPermissions", permissionStatus) }Initialize the Bridgefy SDK
await Bridgefy.initialize({ apiKey: UUID("1b672abe-23bc-412d-94fd-0cb444b3b9e9"), verboseLogging: true, })Start, send, and stop operations
await Bridgefy.start({ propagationProfile: PropagationProfile.HIGH_DENSITY_ENVIRONMENT, }) await Bridgefy.send({ data: btoa("Hello World."), transmissionMode: { type: TransmissionType.BROADCAST, uuid: UUID("1b672abe-23bc-412d-94fd-0cb444b3b9e9"), }, }) await Bridgefy.stop()
Configuration
[!NOTE] An Internet connection is needed at least for the first time in order to validate the license.
Android
A summary of available runtime permissions needed for using Bluetooth:
| Minimum SDK | Maximum SDK | Permissions |
| ----------: | ----------: | :---------- |
| 18 | 22 | (No runtime permissions needed)
| 23 | 28 | android.permission.ACCESS_COARSE_LOCATION android.permission.ACCESS_FINE_LOCATION
| 29 | 30 | android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_BACKGROUND_LOCATION1
| 31 | Current | android.permission.ACCESS_FINE_LOCATION2 android.permission.BLUETOOTH_SCAN android.permission.BLUETOOTH_ADVERTISE android.permission.BLUETOOTH_CONNECT
1 Needed if scan should run in background
2 Needed if scan derives physical location
If your app does not use Bluetooth scan results to derive physical location, you can make a strong assertion that your app never uses the Bluetooth permissions to derive physical location.
🔗 Strongly assert that your app doesn't derive physical location
To use Bluetooth features in your app, you must declare the following permissions in your app’s manifest file:
<!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<!-- https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#discover-local-devices -->
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADVERTISE"
android:minSdkVersion="31" />
<uses-permission
android:name="android.permission.BLUETOOTH_CONNECT"
android:minSdkVersion="31" />
<!-- https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#assert-never-for-location -->
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:minSdkVersion="31"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="31" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="28"
android:minSdkVersion="23"
tools:node="replace" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="32"
android:minSdkVersion="23"
tools:ignore="CoarseFineLocation" />
<uses-permission android:name="android.permission.INTERNET" />If you want to be able to scan in the background, you will have to add the following permission as well:
🔗 Access to device location in the background requires permission
<uses-permission
android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
android:maxSdkVersion="30"
android:minSdkVersion="29" />If your app relies on Bluetooth Low Energy, you can add this requirement to your app’s manifest file:
<!-- https://developer.android.com/develop/connectivity/bluetooth/bt-permissions#features -->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />Additionally, add your Bridgefy API Key into the application component of your app’s manifest file:
<meta-data
android:name="com.bridgefy.sdk.API_KEY"
android:value="123e4567-e89b-12d3-a456-426614174000" />iOS
Add the following properties to your app’s Information Property List file:
A message that tells people why the app needs access to Bluetooth.
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app requires Bluetooth access to communicate with other devices.</string>[!IMPORTANT] If your app has a deployment target earlier than iOS 13, add the
NSBluetoothPeripheralUsageDescriptionkey to your app’s Information Property List file in addition to this key.
A message that tells people why the app is requesting the ability to connect to Bluetooth peripherals.
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app requires Bluetooth access to communicate with other devices.</string>[!IMPORTANT] This key is required if your app uses APIs that access Bluetooth peripherals and has a deployment target earlier than iOS 13.
Application
These configuration values are available:
| Prop | Type | Description | Default | Since |
| ------------------------ | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------- | ----- |
| apiKey | UUID | The API key for Bridgefy. | | 1.0.0 |
| verboseLogging | boolean | If true, enables verbose logging for debugging purposes. | false | 1.0.0 |
| propagationProfile | PropagationProfile | A profile that defines a series of properties and rules for the propagation of messages. | PropagationProfile.STANDARD | 1.1.0 |
Examples
In capacitor.config.json:
{
"plugins": {
"Bridgefy": {
"apiKey": '123e4567-e89b-12d3-a456-426614174000',
"verboseLogging": true,
"propagationProfile": PropagationProfile.HIGH_DENSITY_ENVIRONMENT
}
}
}In capacitor.config.ts:
/// <reference types="@capacitor-trancee/bridgefy" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
Bridgefy: {
apiKey: '123e4567-e89b-12d3-a456-426614174000',
verboseLogging: true,
propagationProfile: PropagationProfile.HIGH_DENSITY_ENVIRONMENT,
},
},
};
export default config;API
initialize(...)isInitialized()start(...)isStarted()stop()licenseExpirationDate()updateLicense()destroySession()currentUserID()connectedPeers()establishSecureConnection(...)fingerprint(...)isFingerprintValid(...)send(...)checkPermissions()requestPermissions(...)addListener('onStarted', ...)addListener('onFailToStart', ...)addListener('onStopped', ...)addListener('onFailToStop', ...)addListener('onDestroySession', ...)addListener('onFailToDestroySession', ...)addListener('onConnected', ...)addListener('onDisconnected', ...)addListener('onConnectedPeers', ...)addListener('onEstablishSecureConnection', ...)addListener('onFailToEstablishSecureConnection', ...)addListener('onSend', ...)addListener('onFailToSend', ...)addListener('onProgress', ...)addListener('onReceive', ...)removeAllListeners()- Interfaces
- Type Aliases
- Enums
initialize(...)
initialize(options?: InitializeOptions | undefined) => Promise<void>Initializes Bridgefy operations.
An Internet connection is needed at least for the first time in order to validate the license.
| Param | Type |
| ------------- | --------------------------------------------------------------- |
| options | InitializeOptions |
Since: 1.0.0
isInitialized()
isInitialized() => Promise<IsInitializedResult>Checks if the Bridgefy SDK has been initialized.
Returns: Promise<IsInitializedResult>
Since: 1.0.0
start(...)
start(options?: StartOptions | undefined) => Promise<void>Starts Bridgefy operations, allowing the SDK to participate in the Bridgefy network.
| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | StartOptions |
Since: 1.0.0
isStarted()
isStarted() => Promise<IsStartedResult>Indicates whether the Bridgefy SDK is currently started.
Returns: Promise<IsStartedResult>
Since: 1.0.0
stop()
stop() => Promise<void>Stops Bridgefy operations and releases associated resources.
Since: 1.0.0
licenseExpirationDate()
licenseExpirationDate() => Promise<LicenseExpirationDateResult>Retrieves the expiration date of the Bridgefy license.
Returns: Promise<LicenseExpirationDateResult>
Since: 1.0.0
updateLicense()
updateLicense() => Promise<void>Updates the Bridgefy license, if necessary.
Only available for Android.
Since: 1.0.0
destroySession()
destroySession() => Promise<void>Destroys the current session, terminating any active connections and cleaning up resources.
Since: 1.0.0
currentUserID()
currentUserID() => Promise<CurrentUserIDResult>Retrieves the UUID of the current Bridgefy user.
Returns: Promise<CurrentUserIDResult>
Since: 1.0.0
connectedPeers()
connectedPeers() => Promise<ConnectedPeersResult>Retrieves a list of UUIDs representing the connected peers in the current session.
Returns: Promise<ConnectedPeersResult>
Since: 1.0.0
establishSecureConnection(...)
establishSecureConnection(options: EstablishSecureConnectionOptions) => Promise<void>Establishes a secure connection with the user.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------- |
| options | EstablishSecureConnectionOptions |
Since: 1.0.0
fingerprint(...)
fingerprint(options: FingerprintOptions) => Promise<FingerprintResult>Generates a fingerprint for the secure connection established with a specified user.
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | FingerprintOptions |
Returns: Promise<FingerprintResult>
Since: 1.0.0
isFingerprintValid(...)
isFingerprintValid(options: IsFingerprintValidOptions) => Promise<IsFingerprintValidResult>Verifies the validity of a fingerprint for a particular user.
| Param | Type |
| ------------- | ------------------------------------------------------------------------------- |
| options | IsFingerprintValidOptions |
Returns: Promise<IsFingerprintValidResult>
Since: 1.0.0
send(...)
send(options: SendOptions) => Promise<SendResult>Sends data using a specific transmission mode.
| Param | Type |
| ------------- | --------------------------------------------------- |
| options | SendOptions |
Returns: Promise<SendResult>
Since: 1.0.0
checkPermissions()
checkPermissions() => Promise<PermissionStatus>Check for the appropriate permissions to use Bridgefy.
Returns: Promise<PermissionStatus>
Since: 1.0.0
requestPermissions(...)
requestPermissions(options?: Permissions | undefined) => Promise<PermissionStatus>Request the appropriate permissions to use Bridgefy.
| Param | Type |
| ------------- | --------------------------------------------------- |
| options | Permissions |
Returns: Promise<PermissionStatus>
Since: 1.0.0
addListener('onStarted', ...)
addListener(eventName: 'onStarted', listenerFunc: OnStartedListener) => Promise<PluginListenerHandle>When the operation has started.
| Param | Type |
| ------------------ | --------------------------------------------------------------- |
| eventName | 'onStarted' |
| listenerFunc | OnStartedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onFailToStart', ...)
addListener(eventName: 'onFailToStart', listenerFunc: OnFailToStartListener) => Promise<PluginListenerHandle>When the start operation has failed.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------- |
| eventName | 'onFailToStart' |
| listenerFunc | OnFailToStartListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onStopped', ...)
addListener(eventName: 'onStopped', listenerFunc: OnStoppedListener) => Promise<PluginListenerHandle>When the operation has been stopped.
| Param | Type |
| ------------------ | --------------------------------------------------------------- |
| eventName | 'onStopped' |
| listenerFunc | OnStoppedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onFailToStop', ...)
addListener(eventName: 'onFailToStop', listenerFunc: OnFailToStopListener) => Promise<PluginListenerHandle>When the stop operation has failed.
| Param | Type |
| ------------------ | --------------------------------------------------------------------- |
| eventName | 'onFailToStop' |
| listenerFunc | OnFailToStopListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onDestroySession', ...)
addListener(eventName: 'onDestroySession', listenerFunc: OnDestroySessionListener) => Promise<PluginListenerHandle>When the session has been destroyed.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------- |
| eventName | 'onDestroySession' |
| listenerFunc | OnDestroySessionListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onFailToDestroySession', ...)
addListener(eventName: 'onFailToDestroySession', listenerFunc: OnFailToDestroySessionListener) => Promise<PluginListenerHandle>When the destroy session operation has failed.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------------- |
| eventName | 'onFailToDestroySession' |
| listenerFunc | OnFailToDestroySessionListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onConnected', ...)
addListener(eventName: 'onConnected', listenerFunc: OnConnectedListener) => Promise<PluginListenerHandle>When a connection to a peer has been established.
| Param | Type |
| ------------------ | ------------------------------------------------------------------- |
| eventName | 'onConnected' |
| listenerFunc | OnConnectedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onDisconnected', ...)
addListener(eventName: 'onDisconnected', listenerFunc: OnDisconnectedListener) => Promise<PluginListenerHandle>When a connection to a peer has been disconnected (out of range).
| Param | Type |
| ------------------ | ------------------------------------------------------------------------- |
| eventName | 'onDisconnected' |
| listenerFunc | OnDisconnectedListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onConnectedPeers', ...)
addListener(eventName: 'onConnectedPeers', listenerFunc: OnConnectedPeersListener) => Promise<PluginListenerHandle>When a peer has been detected, returns the list of connected peers.
Only available for Android.
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------- |
| eventName | 'onConnectedPeers' |
| listenerFunc | OnConnectedPeersListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onEstablishSecureConnection', ...)
addListener(eventName: 'onEstablishSecureConnection', listenerFunc: OnEstablishSecureConnectionListener) => Promise<PluginListenerHandle>When an on-demand secure connection was successfully established.
| Param | Type |
| ------------------ | --------------------------------------------------------------------------------------------------- |
| eventName | 'onEstablishSecureConnection' |
| listenerFunc | OnEstablishSecureConnectionListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onFailToEstablishSecureConnection', ...)
addListener(eventName: 'onFailToEstablishSecureConnection', listenerFunc: OnFailToEstablishSecureConnectionListener) => Promise<PluginListenerHandle>When an on-demand secure connection failed to establish.
| Param | Type |
| ------------------ | --------------------------------------------------------------------------------------------------------------- |
| eventName | 'onFailToEstablishSecureConnection' |
| listenerFunc | OnFailToEstablishSecureConnectionListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onSend', ...)
addListener(eventName: 'onSend', listenerFunc: OnSendListener) => Promise<PluginListenerHandle>When data has been sent.
| Param | Type |
| ------------------ | --------------------------------------------------------- |
| eventName | 'onSend' |
| listenerFunc | OnSendListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onFailToSend', ...)
addListener(eventName: 'onFailToSend', listenerFunc: OnFailToSendListener) => Promise<PluginListenerHandle>When the send operation has failed.
| Param | Type |
| ------------------ | --------------------------------------------------------------------- |
| eventName | 'onFailToSend' |
| listenerFunc | OnFailToSendListener |
Returns: Promise<PluginListenerHandle>
Since: 1.0.0
addListener('onProgress', ...)
addListener(eventName: 'onProgress', listenerFunc: OnProgressListener) => Promise<PluginListenerHandle>When a send operation is in progress.
Only available for Android.
| Param | Type |
| ------------------ | ----------------------------------------------------------------- |
| eventName | 'onProgress' |
| listenerFunc | OnProgressListener |
Returns: Promise<PluginListenerHandle>
Since: 1.2.0
addListener('onReceive', ...)
addListener(eventName: 'onReceive', listenerFunc: OnReceiveListener) => Promise<PluginListenerHandle>When data has been received.
| Param | Type |
| ------------------ | --------------------------------------------------------------- |
| eventName | 'onReceive' |
| listenerFunc | OnReceiveListener |
Returns: Promise<PluginListenerHandle>
Since: 1.2.0
removeAllListeners()
removeAllListeners() => Promise<void>Remove all listeners for this plugin.
Since: 1.0.0
Interfaces
InitializeOptions
| Prop | Type | Description | Since |
| -------------------- | ------------------------------------- | ---------------------------------------------------------- | ----- |
| apiKey | UUID | The API key for Bridgefy. | 1.0.0 |
| verboseLogging | boolean | If true, enables verbose logging for debugging purposes. | 1.0.0 |
IsInitializedResult
| Prop | Type |
| ------------------- | -------------------- |
| isInitialized | boolean |
StartOptions
Propagation Profiles
| Profile | Hops Limit | TTL | Sharing Time | Maximum Propagation | Tracklist Limit | | :----------------------- | ---------: | ---------: | -----------: | ------------------: | --------------: | | Standard | 100 | 400 (1d) | 15000 | 200 | 50 | | High Density Environment | 50 | 600 (1h) | 10000 | 50 | 50 | | Sparse Environment | 100 | 400 (3.5d) | 10000 | 250 | 50 | | Long Reach | 250 | 800 (7d) | 15000 | 1000 | 50 | | Short Reach | 50 | 800 (0.5d) | 10000 | 50 | 50 |
Hops Limit
The maximum number of hops a message can get. Each time a message is forwarded, is considered a hop.
TTL
Time to live, is the maximum amount of time a message can be propagated since its creation.
Sharing Time
The maximum amount of time a message will be kept for forwarding.
Maximum Propagation
The maximum number of times a message will be forwarded from a device.
Tracklist Limit
The maximum number of UUID’s stored in an array to prevent sending the message to a peer which already forwarded the message.
| Prop | Type | Description | Default |
| ------------------------ | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
| userID | UserID | The ID used to identify the user in the Bridgefy network. If not provided, a new user ID will be generated. | |
| propagationProfile | PropagationProfile | A profile that defines a series of properties and rules for the propagation of messages. | PropagationProfile.STANDARD |
IsStartedResult
| Prop | Type |
| --------------- | -------------------- |
| isStarted | boolean |
LicenseExpirationDateResult
| Prop | Type | Description | Since |
| --------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| licenseExpirationDate | number | The expiration date of the license. The time in milliseconds that has elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC (equivalent to the UNIX epoch). This timestamp is timezone-agnostic and uniquely defines an instant in history. | 1.0.0 |
CurrentUserIDResult
| Prop | Type |
| ------------ | ----------------------------------------- |
| userID | UserID |
ConnectedPeersResult
| Prop | Type |
| ----------- | ------------------- |
| peers | UUID[] |
EstablishSecureConnectionOptions
| Prop | Type |
| ------------ | ----------------------------------------- |
| userID | UserID |
FingerprintResult
| Prop | Type |
| ----------------- | ----------------------------------------- |
| fingerprint | Base64 |
FingerprintOptions
| Prop | Type |
| ------------ | ----------------------------------------- |
| userID | UserID |
IsFingerprintValidResult
| Prop | Type |
| ------------- | -------------------- |
| isValid | boolean |
IsFingerprintValidOptions
| Prop | Type |
| ----------------- | ----------------------------------------- |
| userID | UserID |
| fingerprint | Base64 |
SendResult
| Prop | Type |
| --------------- | ----------------------------------------------- |
| messageID | MessageID |
SendOptions
| Prop | Type |
| ---------------------- | ------------------------------------------------------------- |
| data | Base64 |
| transmissionMode | TransmissionMode |
TransmissionMode
There are several modes for sending packets:
- Broadcast Sends a packet using mesh without a defined receiver. The packet is broadcast to all nearby users that are in range, who then broadcast it to all receivers that are in their range, and so on. If a user isn’t in range, the packet will be delivered the next time said user comes within range of another user who did receive the packet. Broadcast messages can be read by all nodes that receive it.
- Mesh Sends the packet using mesh to only once receiver. It doesn’t need the receiver to be in range. Receiver can be in range of a third receiver located within range of both sender and receiver at the same time, or receiver can be out of range of all other nodes, but eventually come within range of a node that at some point received the packet. Mesh messages can be received by multiple nodes, but can only be read by the intended receiver.
- P2P Sends the packet only when the receiver is in range.
| Prop | Type |
| ---------- | ------------------------------------------------------------- |
| type | TransmissionType |
| uuid | UUID |
PermissionStatus
| Prop | Type | Description | Since |
| ---------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| bluetooth | PermissionState | BLUETOOTH_ADVERTISE Required to be able to advertise to nearby Bluetooth devices. BLUETOOTH_CONNECT Required to be able to connect to paired Bluetooth devices. BLUETOOTH_SCAN Required to be able to discover and pair nearby Bluetooth devices. BLUETOOTH Allows applications to connect to paired bluetooth devices. BLUETOOTH_ADMIN Allows applications to discover and pair bluetooth devices. | 1.0.0 |
| location | PermissionState | ACCESS_FINE_LOCATION Allows an app to access precise location. Only available for Android. | 1.0.0 |
|
background | PermissionState | ACCESS_BACKGROUND_LOCATION Allows an app to access location in the background. Only available for Android. | 1.1.0 |
Permissions
| Prop | Type |
| ----------------- | ----------------------------- |
| permissions | PermissionType[] |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
OnStartedEvent
| Prop | Type |
| ------------ | ----------------------------------------- |
| userID | UserID |
OnFailToStartEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | --------------------------- | ----- |
| reason | Reason | The reason for the failure. | 1.0.0 |
Reason
| Prop | Type |
| ------------- | ------------------------------------------------- |
| type | ReasonType |
| message | string |
| code | number |
OnFailToStopEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | --------------------------- | ----- |
| reason | Reason | The reason for the failure. | 1.0.0 |
OnFailToDestroySessionEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | --------------------------- | ----- |
| reason | Reason | The reason for the failure. | 1.0.0 |
OnConnectedEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | --------------------------------------------------------- | ----- |
| peerID | PeerID | Identifier of the peer that has established a connection. | 1.0.0 |
OnDisconnectedEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | ------------------------------------ | ----- |
| peerID | PeerID | Identifier of the disconnected peer. | 1.0.0 |
OnConnectedPeersEvent
| Prop | Type | Description | Since |
| ----------- | ------------------- | ------------------------------------------- | ----- |
| peers | UUID[] | List of identifiers of the connected peers. | 1.0.0 |
OnEstablishSecureConnectionEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | ---------------------------------------------------------------------- | ----- |
| userID | UserID | Identifier of the user with whom the secure connection is established. | 1.0.0 |
OnFailToEstablishSecureConnectionEvent
| Prop | Type | Description | Since |
| ------------ | ----------------------------------------- | --------------------------------------------------------------------- | ----- |
| userID | UserID | Identifier of the user with whom the secure connection was attempted. | 1.0.0 |
| reason | Reason | The reason for the failure. | 1.0.0 |
OnSendEvent
| Prop | Type | Description | Since |
| --------------- | ----------------------------------------------- | ------------------------------- | ----- |
| messageID | MessageID | Identifier of the sent message. | 1.0.0 |
OnFailToSendEvent
| Prop | Type | Description | Since |
| --------------- | ----------------------------------------------- | --------------------------------- | ----- |
| messageID | MessageID | Identifier of the failed message. | 1.0.0 |
| reason | Reason | The reason for the failure. | 1.0.0 |
OnProgressEvent
| Prop | Type | Description | Since |
| --------------- | ----------------------------------------------- | ------------------------------------------- | ----- |
| messageID | MessageID | Identifier of the message being sent. | 1.0.0 |
| position | number | Current position of the message being sent. | 1.0.0 |
| of | number | Total size of the message being sent. | 1.0.0 |
OnReceiveEvent
| Prop | Type | Description | Since |
| ---------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------- | ----- |
| messageID | MessageID | Identifier of the received message. | 1.0.0 |
| data | Base64 | The received data, encoded as a Base64 string. | 1.0.0 |
| transmissionMode | TransmissionMode | The transmission mode used when sending the message. | 1.0.0 |
Type Aliases
UUID
string & { readonly __brand: unique symbol }
UserID
UUID
PeerID
UUID
Base64
string & { readonly __brand: unique symbol }
MessageID
UUID
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
PermissionType
'bluetooth' | 'location' | 'background'
OnStartedListener
(event: OnStartedEvent): void
OnFailToStartListener
(event: OnFailToStartEvent): void
OnStoppedListener
(event: void): void
OnFailToStopListener
(event: OnFailToStopEvent): void
OnDestroySessionListener
(event: void): void
OnFailToDestroySessionListener
(event: OnFailToDestroySessionEvent): void
OnConnectedListener
(event: OnConnectedEvent): void
OnDisconnectedListener
(event: OnDisconnectedEvent): void
OnConnectedPeersListener
(event: OnConnectedPeersEvent): void
OnEstablishSecureConnectionListener
(event: OnEstablishSecureConnectionEvent): void
OnFailToEstablishSecureConnectionListener
(event: OnFailToEstablishSecureConnectionEvent): void
OnSendListener
(event: OnSendEvent): void
OnFailToSendListener
(event: OnFailToSendEvent): void
OnProgressListener
(event: OnProgressEvent): void
OnReceiveListener
(event: OnReceiveEvent): void
Enums
PropagationProfile
| Members | Value | Description | Since |
| ------------------------------ | ------------------------------------- | ------------------------------------------------------------------------ | ----- |
| STANDARD | 'standard' | Represents a standard propagation profile. | 1.0.0 |
| HIGH_DENSITY_ENVIRONMENT | 'highDensityEnvironment' | Indicates a propagation profile suitable for high-density networks. | 1.0.0 |
| SPARSE_ENVIRONMENT | 'sparseEnvironment' | Represents a propagation profile tailored for sparse networks. | 1.0.0 |
| LONG_REACH | 'longReach' | Indicates a propagation profile optimized for long reach. | 1.0.0 |
| SHORT_REACH | 'shortReach' | Represents a propagation profile designed for short reach communication. | 1.0.0 |
TransmissionType
| Members | Value | Description | Since |
| --------------- | ------------------------ | --------------------------------------------------------------------------------------- | ----- |
| BROADCAST | 'broadcast' | Propagate a message readable by every device that receives it. | 1.0.0 |
| MESH | 'mesh' | Deliver a message to a specific recipient using nearby devices to propagate it. | 1.0.0 |
| P2P | 'p2p' | Deliver a message to a specific recipient only if there’s an active connection with it. | 1.0.0 |
ReasonType
| Members | Value | Description | Since |
| ------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----- |
| ALREADY_STARTED | 'alreadyStarted' | The Bridgefy SDK is already running. | 1.0.0 |
| EXPIRED_LICENSE | 'expiredLicense' | The license is expired. | 1.0.0 |
| INCONSISTENT_DEVICE_TIME | 'inconsistentDeviceTime' | The device’s time has been modified. | 1.0.0 |
| INTERNET_CONNECTION_REQUIRED | 'internetConnectionRequired' | An internet connection is required to validate the license. | 1.0.0 |
| INVALID_API_KEY | 'invalidAPIKey' | The provided API key is invalid. | 1.0.0 |
| SESSION_ERROR | 'sessionError' | An error occurred while creating the session. | 1.0.0 |
| SIMULATOR_IS_NOT_SUPPORTED | 'simulatorIsNotSupported' | The Bridgefy SDK cannot run in the simulator. | 1.0.0 |
| DEVICE_CAPABILITIES | 'deviceCapabilities' | Only available for Android. | 1.0.0 |
|
GENERIC | 'generic' | Only available for Android. | 1.0.0 |
|
MISSING_APPLICATION_ID | 'missingApplicationID' | Only available for Android. | 1.0.0 |
|
PERMISSION | 'permission' | Only available for Android. | 1.0.0 |
|
REGISTRATION | 'registration' | Only available for Android. | 1.0.0 |
|
SIZE_LIMIT_EXCEEDED | 'sizeLimitExceeded' | Only available for Android. | 1.0.0 |
|
UNKNOWN | 'unknown' | Only available for Android. | 1.0.0 |
|
MISSING_BUNDLE_ID | 'missingBundleID' | Cannot get app’s bundle ID. Only available for iOS. | 1.0.0 |
|
INCONSISTENT_USER_ID | 'inconsistentUserID' | The userId passed in the start function is different from the stored one. Only available for iOS. | 1.0.0 |
|
NOT_STARTED | 'notStarted' | The Bridgefy SDK hasn’t been started. Only available for iOS. | 1.0.0 |
|
ALREADY_INSTANTIATED | 'alreadyInstantiated' | A Bridgefy SDK instance already exists. Only available for iOS. | 1.0.0 |
|
START_IN_PROGRESS | 'startInProgress' | The Bridgefy SDK is performing the start process. Only available for iOS. | 1.0.0 |
|
STOP_IN_PROGRESS | 'stopInProgress' | The Bridgefy SDK is performing the stop process. Only available for iOS. | 1.0.0 |
|
DESTROY_SESSION_IN_PROGRESS | 'destroySessionInProgress' | The Bridgefy SDK is destroying the current session. Only available for iOS. | 1.0.0 |
|
SERVICE_NOT_STARTED | 'serviceNotStarted' | The Bridgefy SDK service is not started. Only available for iOS. | 1.0.0 |
|
BLE_USAGE_NOT_GRANTED | 'BLEUsageNotGranted' | The user does not allow the use of BLE. Only available for iOS. | 1.0.0 |
|
BLE_USAGE_RESTRICTED | 'BLEUsageRestricted' | The use of BLE in this device is restricted. Only available for iOS. | 1.0.0 |
|
BLE_POWERED_OFF | 'BLEPoweredOff' | The BLE antenna has been turned off. Only available for iOS. | 1.0.0 |
|
BLE_UNSUPPORTED | 'BLEUnsupported' | The usage of BLE is not supported in the device. Only available for iOS. | 1.0.0 |
|
BLE_UNKNOWN_ERROR | 'BLEUnknownError' | BLE usage failed with an unknown error. Only available for iOS. | 1.0.0 |
|
INCONSISTENT_CONNECTION | 'inconsistentConnection' | | |
| CONNECTION_IS_ALREADY_SECURE | 'connectionIsAlreadySecure' | | |
| CANNOT_CREATE_SECURE_CONNECTION | 'cannotCreateSecureConnection' | | |
| DATA_LENGTH_EXCEEDED | 'dataLengthExceeded' | The length of the data exceed the maximum limit. Only available for iOS. | 1.0.0 |
|
DATA_VALUE_IS_EMPTY | 'dataValueIsEmpty' | The data to send is empty. Only available for iOS. | 1.0.0 |
|
PEER_IS_NOT_CONNECTED | 'peerIsNotConnected' | The requested peer is not connected. Only available for iOS. | 1.0.0 |
|
INTERNAL_ERROR | 'internalError' | An internal error occurred. Only available for iOS. | 1.0.0 |
|
LICENSE_ERROR | 'licenseError' | An error occurred while validating the license. Only available for iOS. | 1.0.0 |
|
STORAGE_ERROR | 'storageError' | An error occurred while storing data. Only available for iOS. | 1.0.0 |
|
ENCODING_ERROR | 'encodingError' | An error occurred while encoding the message. Only available for iOS. | 1.0.0 |
|
ENCRYPTION_ERROR | 'encryptionError' | An error occurred while encrypting the message. Only available for iOS. | 1.0.0 |
