bridgefy 1.1.4 bridgefy: ^1.1.4 copied to clipboard
The Bridgefy SDK is a state-of-the-art, plug-and-play package that lets people use apps when they don’t have access to the Internet by using mesh networ
Bridgefy Flutter SDK #
The Bridgefy Software Development Kit (SDK) is a state-of-the-art, plug-and-play package that will let people use your mobile app when they don’t have access to the Internet, by using Bluetooth mesh networks.
Integrate the Bridgefy SDK into your Android and iOS app to reach the 3.5 billion people that don’t always have access to an Internet connection, and watch engagement and revenue grow!
Website. https://bridgefy.me/sdk
Email. contact@bridgefy.me
witter. https://twitter.com/bridgefy
Facebook. https://www.facebook.com/bridgefy
Operation mode #
All the connections are handled seamlessly by the SDK to create a mesh network. The size of this network depends on the number of devices connected and the environment as a variable factor, allowing you to join nodes in the same network or nodes in different networks.
Platform permissions #
To utilize this SDK in a Flutter application, you'll need to configure permissions for each individual platform (iOS and Android) first. You can read more about each platform's requirements below:
Installation #
To install this SDK, you'll need to either add the following to your pubspec.yaml
file:
dependencies:
bridgefy: ^1.1.4
Or run this flutter command:
flutter pub add bridgefy
Usage #
Initialization #
The init method initializes the Bridgefy SDK with the given API key and verbose logging. The
delegate parameter is required and should be an object that conforms to the BridgefyDelegate
mixin.
The following code shows how to init the SDK (using your API key) and how to assign the delegate.
import 'package:bridgefy/bridgefy.dart';
class _MyAppState extends State<MyApp> implements BridgefyDelegate {
final _bridgefy = Bridgefy();
@override
void initState() {
super.initState();
try {
await _bridgefy.initialize(
apiKey: "<API_KEY>",
delegate: this,
verboseLogging: true,
);
} catch (e) {
_log("Unable to initialize: $e");
}
}
Start Bridgefy #
The following code shows how to start the SDK with propagation profile and custom user Id.
_bridgefy.start(
userId: "Custom UUID",
propagationProfile: BridgefyPropagationProfile.standard
);
Stop Bridgefy #
Stop Bridgefy operations
_bridgefy.stop();
Sending data #
The following method is used to send data using a transmission mode. This method returns a UUID to identify the message sent.
void _send() async {
final lastMessageId = await _bridgefy.send(
data: _data, // Uint8List data to send
transmissionMode: BridgefyTransmissionMode(
type: BridgefyTransmissionModeType.broadcast,
uuid: await _bridgefy.currentUserID,
),
);
}
Responding to SDK events #
The SDK will report events to your app through the BridgefyDelegate
object you specified upon
initialization.
The following is an example event emitted when a message is successfully sent:
@override
void bridgefyDidSendMessage({required String messageID}) {
// `messageID` The id of the message sent successfully.
}
// This function is called when the message could not be sent.
@override
void bridgefyDidFailSendingMessage({required String messageID, BridgefyError? error}) {
// `messageID`: The id of the message that was tried to be sent.
// `error`: Error reason.
}
When the app received data through Bridgefy:
@override
void bridgefyDidReceiveData({
required Uint8List data,
required String messageId,
required BridgefyTransmissionMode transmissionMode,
}) {
// `data` contains the message bytes.
}
Transmission Mode #
BridgefyTransmissionModeType
specifies different transmission modes:
p2p
: Deliver a message to a specific recipient only if there's an active connection with it.mesh
: Deliver a message to a specific recipient using nearby devices to propagate it.broadcast
: Propagate a message readable by every device that receives it.
PropagationProfile #
BridgefyPropagationProfile
defines different propagation profiles within the BridgefySDK.
standard
: Represents a standard propagation profile.highDensityNetwork
: Indicates a propagation profile suitable for high-density networks.sparseNetwork
: Represents a propagation profile tailored for sparse networks.longReach
: Indicates a propagation profile optimized for long reach.shortReach
: Represents a propagation profile designed for short reach communication.
Nearby peer detection #
The following method is invoked when a peer has established connection:
@override
void bridgefyDidConnect({required String userID}) {
// `userID` the peer connected
}
When a peer is disconnected(out of range), the following method will be invoked:
@override
void bridgefyDidDisconnect({required String userID}) {
// `userID` the peer disconnected
}
To see a full list of events, take a look at the BridgefyDelegate
mixin.
Other Utilities #
Retrieve current user ID:
String currentUserID = await _bridgefy.currentUserID;
Get a list of connected peers:
List<String> connectedPeers = await _bridgefy.connectedPeers;
Check if the SDK is initialized or started:
bool isInitialized = await _bridgefy.isInitialized;
bool isStarted = await _bridgefy.isStarted;
Retrieve license expiration date:
DateTime? expirationDate = await _bridgefy.licenseExpirationDate;
License Update #
Update the license:
await _bridgefy.updateLicense();
Multi-Platform Support #
Bridgefy's SDKs are designed to work seamlessly across different platforms, including iOS and Android. This means that users with different devices can communicate with each other as long as they have the Bridgefy-enabled applications installed.
Contact & Support #
© 2023 Bridgefy Inc. All rights reserved