Skip to content

Commit 1898954

Browse files
Release/v1.1.3 (#31)
- chore: update version 1.1.2 -> 1.1.3 - chore: bridgefy started and initialized flags - chore: upgrade iOS framework 1.1.2 - chore: update android SDK 1.1.2 - chore: update readme
1 parent 02f49b5 commit 1898954

39 files changed

+35423
-3025
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Bridgefy Flutter 1.1.2
1+
# Bridgefy Flutter 1.1.3
22
### BLUETOOTH MESH NETWORKS
33

44
Devices running your app create Bluetooth Low-Energy mesh networks, which work in large crowds, during and after natural disasters, and whenever else your users lose access to the Internet.

README.md

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
<p align="center">
42
<img src="https://www.gitbook.com/cdn-cgi/image/width=256,dpr=2,height=40,fit=contain,format=auto/https%3A%2F%2F3290834949-files.gitbook.io%2F~%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F5XKIMMP6VF2l9XuPV80l%252Flogo%252Fd78nQFIysoU2bbM5fYNP%252FGroup%25203367.png%3Falt%3Dmedia%26token%3Df83a642d-8a9a-411f-9ef4-d7189a4c5f0a" />
53
</p>
@@ -44,7 +42,7 @@ To install this SDK, you'll need to either add the following to your `pubspec.ya
4442

4543
```yaml
4644
dependencies:
47-
bridgefy: ^1.1.2
45+
bridgefy: ^1.1.3
4846
```
4947
5048
Or run this flutter command:
@@ -58,8 +56,7 @@ flutter pub add bridgefy
5856
### Initialization
5957

6058
The init method initializes the Bridgefy SDK with the given API key and verbose logging. The
61-
delegate parameter is required and should be an object that conforms to the `BridgefyDelegate`
62-
mixin.
59+
delegate parameter is required and should be an object that conforms to the `BridgefyDelegate`mixin.
6360

6461
The following code shows how to init the SDK (using your API key) and how to assign the delegate.
6562

@@ -96,6 +93,14 @@ The following code shows how to start the SDK with propagation profile and custo
9693
9794
````
9895

96+
### Stop Bridgefy
97+
98+
Stop Bridgefy operations
99+
```dart
100+
_bridgefy.stop();
101+
```
102+
103+
99104
### Sending data
100105

101106
The following method is used to send data using a transmission mode. This method returns a UUID to
@@ -123,10 +128,18 @@ The following is an example event emitted when a message is successfully sent:
123128
```dart
124129
@override
125130
void bridgefyDidSendMessage({required String messageID}) {
126-
// `messageID` contains the ID of the message.
131+
// `messageID` The id of the message sent successfully.
132+
}
133+
134+
// This function is called when the message could not be sent.
135+
@override
136+
void bridgefyDidFailSendingMessage({required String messageID, BridgefyError? error}) {
137+
// `messageID`: The id of the message that was tried to be sent.
138+
// `error`: Error reason.
127139
}
128140
```
129141

142+
130143
When the app received data through Bridgefy:
131144

132145
```dart
@@ -140,6 +153,24 @@ void bridgefyDidReceiveData({
140153
}
141154
```
142155

156+
### Transmission Mode
157+
158+
`BridgefyTransmissionModeType` specifies different transmission modes:
159+
160+
- `p2p`: Deliver a message to a specific recipient only if there's an active connection with it.
161+
- `mesh`: Deliver a message to a specific recipient using nearby devices to propagate it.
162+
- `broadcast`: Propagate a message readable by every device that receives it.
163+
164+
### PropagationProfile
165+
166+
`BridgefyPropagationProfile` defines different propagation profiles within the BridgefySDK.
167+
168+
- `standard`: Represents a standard propagation profile.
169+
- `highDensityNetwork`: Indicates a propagation profile suitable for high-density networks.
170+
- `sparseNetwork`: Represents a propagation profile tailored for sparse networks.
171+
- `longReach`: Indicates a propagation profile optimized for long reach.
172+
- `shortReach`: Represents a propagation profile designed for short reach communication.
173+
143174
### Nearby peer detection
144175

145176
The following method is invoked when a peer has established connection:
@@ -162,6 +193,43 @@ When a peer is disconnected(out of range), the following method will be invoked:
162193

163194
To see a full list of events, take a look at the `BridgefyDelegate` mixin.
164195

196+
### Other Utilities
197+
198+
Retrieve current user ID:
199+
200+
```dart
201+
String currentUserID = await _bridgefy.currentUserID;
202+
```
203+
204+
Get a list of connected peers:
205+
206+
207+
```dart
208+
List<String> connectedPeers = await _bridgefy.connectedPeers;
209+
```
210+
211+
Check if the SDK is initialized or started:
212+
213+
```dart
214+
bool isInitialized = await _bridgefy.isInitialized;
215+
bool isStarted = await _bridgefy.isStarted;
216+
```
217+
218+
Retrieve license expiration date:
219+
220+
221+
```dart
222+
DateTime? expirationDate = await _bridgefy.licenseExpirationDate;
223+
```
224+
225+
### License Update
226+
Update the license:
227+
228+
```dart
229+
await _bridgefy.updateLicense();
230+
```
231+
232+
165233
## Multi-Platform Support
166234

167235
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.

android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ rootProject.allprojects {
2020
url "http://34.82.5.94:8081/artifactory/libs-release-local"
2121
allowInsecureProtocol = true
2222
}
23+
flatDir {
24+
dirs("/Users/bridgefy/bridgefy/sdk/bridgefy_flutter/android/libs")
25+
}
2326
}
2427
}
2528

@@ -55,7 +58,7 @@ android {
5558
}
5659

5760
dependencies {
58-
implementation (group: "me.bridgefy", name: "android-sdk", version: "1.1.1", ext: "aar") {
61+
implementation (group: "me.bridgefy", name: "android-sdk", version: "1.1.2", ext: "aar") {
5962
transitive = true
6063
}
6164
}

android/src/main/kotlin/me/bridgefy/plugin/flutter/BridgefyPlugin.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class BridgefyPlugin : FlutterPlugin, MethodCallHandler {
4444
"licenseExpirationDate" -> licenseExpirationDate(call, result)
4545
"destroySession" -> destroySession(call, result)
4646
"updateLicense" -> updateLicense(call, result)
47+
"isInitialized" -> isInitialized(call, result)
48+
"isStarted" -> isStarted(call, result)
4749
else -> result.notImplemented()
4850
}
4951
}
@@ -173,9 +175,16 @@ class BridgefyPlugin : FlutterPlugin, MethodCallHandler {
173175
if (verboseLogging) Log.DEBUG else 1,
174176
)
175177
result.success(null)
178+
} catch (illegal: IllegalArgumentException) {
179+
illegal.printStackTrace()
180+
result.error("invalidAPIKey", illegal.message ?: illegal.localizedMessage, null)
176181
} catch (error: BridgefyException) {
182+
error.printStackTrace()
177183
val map = mapFromBridgefyException(error)
178184
result.error(map["code"] as String, map["message"] as String, map["details"])
185+
} catch (e: Exception) {
186+
e.printStackTrace()
187+
result.error("sessionError", e.message ?: e.localizedMessage, null)
179188
}
180189
}
181190

@@ -242,6 +251,14 @@ class BridgefyPlugin : FlutterPlugin, MethodCallHandler {
242251
result.success(null)
243252
}
244253

254+
private fun isInitialized(@NonNull call: MethodCall, @NonNull result: Result) {
255+
result.success(hashMapOf("isInitialized" to bridgefy.isInitialized))
256+
}
257+
258+
private fun isStarted(@NonNull call: MethodCall, @NonNull result: Result) {
259+
result.success(hashMapOf("isStarted" to bridgefy.isStarted))
260+
}
261+
245262
private fun mapFromBridgefyException(exception: BridgefyException): HashMap<String, Any?> {
246263
var code: String
247264
var details: Int? = null

example/lib/main.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class _MyAppState extends State<MyApp> implements BridgefyDelegate {
2020
String apiKey = "YOUR_API_KEY_HERE";
2121
final _bridgefy = Bridgefy();
2222
bool _didStart = false;
23-
String _buttonText = 'Start';
2423
String _logStr = '';
2524
final Color _bfColor = const Color(0x00FF4040);
2625
final _scrollController = ScrollController();
@@ -55,11 +54,16 @@ class _MyAppState extends State<MyApp> implements BridgefyDelegate {
5554
super.initState();
5655
checkPermissions().then((value) async {
5756
try {
58-
await _bridgefy.initialize(
59-
apiKey: apiKey,
60-
delegate: this,
61-
verboseLogging: true,
62-
);
57+
//you can validate if there is already an initialized instance to avoid an error in case it already exists
58+
final isInitialized = await _bridgefy.isInitialized;
59+
_didStart = await _bridgefy.isStarted;
60+
if (!isInitialized){
61+
await _bridgefy.initialize(
62+
apiKey: apiKey,
63+
delegate: this,
64+
verboseLogging: true,
65+
);
66+
}
6367
} catch (e) {
6468
_log("Unable to initialize: $e");
6569
}
@@ -95,7 +99,7 @@ class _MyAppState extends State<MyApp> implements BridgefyDelegate {
9599
? const Icon(Icons.stop_circle)
96100
: const Icon(Icons.check_circle),
97101
onPressed: _toggleStart,
98-
label: Text(_buttonText)),
102+
label: Text(_didStart ? "Stop" : "Start")),
99103
const SizedBox(width: 7),
100104
ElevatedButton.icon(
101105
icon: const Icon(Icons.send),
@@ -222,7 +226,6 @@ class _MyAppState extends State<MyApp> implements BridgefyDelegate {
222226
_log("bridgefyDidStart: $currentUserID");
223227
setState(() {
224228
_didStart = true;
225-
_buttonText = 'Stop';
226229
});
227230
}
228231

@@ -231,7 +234,6 @@ class _MyAppState extends State<MyApp> implements BridgefyDelegate {
231234
_log("bridgefyDidStop");
232235
setState(() {
233236
_didStart = false;
234-
_buttonText = 'Start';
235237
});
236238
}
237239

ios/Classes/BridgefyPlugin.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public class BridgefyPlugin: NSObject, FlutterPlugin, BridgefyDelegate {
3636
case "currentUserID":
3737
currentUserID(call, result: result)
3838
break
39+
case "isInitialized":
40+
isInitialized(call, result: result)
41+
break
42+
case "isStarted":
43+
isStarted(call, result: result)
44+
break
3945
case "establishSecureConnection":
4046
establishSecureConnection(call, result: result)
4147
break
@@ -190,8 +196,16 @@ public class BridgefyPlugin: NSObject, FlutterPlugin, BridgefyDelegate {
190196
})])
191197
}
192198

199+
private func isInitialized(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
200+
result(["isInitialized": Bridgefy.isInitialized])
201+
}
202+
203+
private func isStarted(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
204+
result(["isStarted": Bridgefy.isStarted])
205+
}
206+
193207
private func currentUserID(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
194-
result(["userId": bridgefy!.currentUserId!.uuidString])
208+
result(["userId": bridgefy!.currentUserId!.uuidString])
195209
}
196210

197211
private func establishSecureConnection(_ call: FlutterMethodCall,

ios/Frameworks/BridgefySDK.xcframework/Info.plist

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,39 @@
55
<key>AvailableLibraries</key>
66
<array>
77
<dict>
8+
<key>BinaryPath</key>
9+
<string>BridgefySDK.framework/BridgefySDK</string>
810
<key>DebugSymbolsPath</key>
911
<string>dSYMs</string>
1012
<key>LibraryIdentifier</key>
11-
<string>ios-arm64_x86_64-simulator</string>
13+
<string>ios-arm64</string>
1214
<key>LibraryPath</key>
1315
<string>BridgefySDK.framework</string>
1416
<key>SupportedArchitectures</key>
1517
<array>
1618
<string>arm64</string>
17-
<string>x86_64</string>
1819
</array>
1920
<key>SupportedPlatform</key>
2021
<string>ios</string>
21-
<key>SupportedPlatformVariant</key>
22-
<string>simulator</string>
2322
</dict>
2423
<dict>
24+
<key>BinaryPath</key>
25+
<string>BridgefySDK.framework/BridgefySDK</string>
2526
<key>DebugSymbolsPath</key>
2627
<string>dSYMs</string>
2728
<key>LibraryIdentifier</key>
28-
<string>ios-arm64</string>
29+
<string>ios-arm64_x86_64-simulator</string>
2930
<key>LibraryPath</key>
3031
<string>BridgefySDK.framework</string>
3132
<key>SupportedArchitectures</key>
3233
<array>
3334
<string>arm64</string>
35+
<string>x86_64</string>
3436
</array>
3537
<key>SupportedPlatform</key>
3638
<string>ios</string>
39+
<key>SupportedPlatformVariant</key>
40+
<string>simulator</string>
3741
</dict>
3842
</array>
3943
<key>CFBundlePackageType</key>
-163 KB
Binary file not shown.

ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Headers/BridgefySDK-Swift.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#if 0
22
#elif defined(__arm64__) && __arm64__
3-
// Generated by Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
3+
// Generated by Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
44
#ifndef BRIDGEFYSDK_SWIFT_H
55
#define BRIDGEFYSDK_SWIFT_H
66
#pragma clang diagnostic push
@@ -42,12 +42,18 @@
4242
#include <string.h>
4343
#endif
4444
#if defined(__cplusplus)
45-
#if __has_include(<ptrauth.h>)
45+
#if defined(__arm64e__) && __has_include(<ptrauth.h>)
4646
# include <ptrauth.h>
4747
#else
48+
#pragma clang diagnostic push
49+
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
4850
# ifndef __ptrauth_swift_value_witness_function_pointer
4951
# define __ptrauth_swift_value_witness_function_pointer(x)
5052
# endif
53+
# ifndef __ptrauth_swift_class_method_pointer
54+
# define __ptrauth_swift_class_method_pointer(x)
55+
# endif
56+
#pragma clang diagnostic pop
5157
#endif
5258
#endif
5359

@@ -246,6 +252,17 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
246252
#else
247253
# define SWIFT_NOEXCEPT
248254
#endif
255+
#if !defined(SWIFT_C_INLINE_THUNK)
256+
# if __has_attribute(always_inline)
257+
# if __has_attribute(nodebug)
258+
# define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline)) __attribute__((nodebug))
259+
# else
260+
# define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline))
261+
# endif
262+
# else
263+
# define SWIFT_C_INLINE_THUNK inline
264+
# endif
265+
#endif
249266
#if defined(_WIN32)
250267
#if !defined(SWIFT_IMPORT_STDLIB_SYMBOL)
251268
# define SWIFT_IMPORT_STDLIB_SYMBOL __declspec(dllimport)
@@ -282,12 +299,12 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
282299
#if defined(__OBJC__)
283300

284301

285-
#endif
286-
#if defined(__cplusplus)
287302
#endif
288303
#if __has_attribute(external_source_symbol)
289304
# pragma clang attribute pop
290305
#endif
306+
#if defined(__cplusplus)
307+
#endif
291308
#pragma clang diagnostic pop
292309
#endif
293310

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)