bridgefy-react-native 1.1.8 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +582 -112
- package/android/build.gradle +36 -56
- package/android/gradle.properties +4 -4
- package/android/src/main/AndroidManifest.xml +1 -11
- package/android/src/main/java/me/bridgefy/plugin/react_native/BridgefyReactNativeModule.kt +609 -332
- package/android/src/main/java/me/bridgefy/plugin/react_native/BridgefyReactNativePackage.kt +25 -8
- package/android/src/main/java/me/bridgefy/plugin/react_native/service/BridgefyService.kt +625 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/BridgefyOperationModeManager.kt +193 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/BridgefyServiceManager.kt +123 -0
- package/android/src/main/java/me/bridgefy/plugin/react_native/util/Utils.kt +172 -0
- package/bridgefy-react-native.podspec +5 -25
- package/ios/BridgefyReactNativeModule.m +88 -0
- package/ios/BridgefyReactNativeModule.swift +524 -0
- package/lib/module/NativeBridgefy.js +114 -0
- package/lib/module/NativeBridgefy.js.map +1 -0
- package/lib/module/index.js +167 -208
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeBridgefy.d.ts +248 -0
- package/lib/typescript/src/NativeBridgefy.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +140 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +77 -74
- package/src/NativeBridgefy.ts +317 -0
- package/src/index.tsx +270 -226
- package/ios/BridgefyReactNative.m +0 -56
- package/ios/BridgefyReactNative.swift +0 -368
- package/ios/BridgefyReactNative.xcodeproj/project.pbxproj +0 -293
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/BridgefyReactNative.xcodeproj/project.xcworkspace/xcuserdata/bridgefy.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/BridgefyReactNative.xcodeproj/xcuserdata/bridgefy.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/Frameworks/BridgefySDK.xcframework/Info.plist +0 -48
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Headers/BridgefySDK-Swift.h +0 -317
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Headers/BridgefySDK.h +0 -15
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Info.plist +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.abi.json +0 -5523
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/Modules/module.modulemap +0 -11
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/BridgefySDK.framework/_CodeSignature/CodeResources +0 -190
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Info.plist +0 -20
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/aarch64/BridgefySDK.yml +0 -12529
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Headers/BridgefySDK-Swift.h +0 -630
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Headers/BridgefySDK.h +0 -15
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Info.plist +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -5523
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -5523
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/BridgefySDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -116
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/Modules/module.modulemap +0 -11
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/BridgefySDK.framework/_CodeSignature/CodeResources +0 -245
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Info.plist +0 -20
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/DWARF/BridgefySDK +0 -0
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/aarch64/BridgefySDK.yml +0 -12276
- package/ios/Frameworks/BridgefySDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/BridgefySDK.framework.dSYM/Contents/Resources/Relocations/x86_64/BridgefySDK.yml +0 -11932
- package/lib/commonjs/index.js +0 -278
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/infraestructure/index.js +0 -28
- package/lib/commonjs/infraestructure/index.js.map +0 -1
- package/lib/commonjs/infraestructure/interfaces/ibridgefy.js +0 -6
- package/lib/commonjs/infraestructure/interfaces/ibridgefy.js.map +0 -1
- package/lib/commonjs/infraestructure/interfaces/index.js +0 -17
- package/lib/commonjs/infraestructure/interfaces/index.js.map +0 -1
- package/lib/commonjs/infraestructure/services/bridgefy_service.js +0 -6
- package/lib/commonjs/infraestructure/services/bridgefy_service.js.map +0 -1
- package/lib/commonjs/infraestructure/services/index.js +0 -17
- package/lib/commonjs/infraestructure/services/index.js.map +0 -1
- package/lib/module/infraestructure/index.js +0 -3
- package/lib/module/infraestructure/index.js.map +0 -1
- package/lib/module/infraestructure/interfaces/ibridgefy.js +0 -2
- package/lib/module/infraestructure/interfaces/ibridgefy.js.map +0 -1
- package/lib/module/infraestructure/interfaces/index.js +0 -2
- package/lib/module/infraestructure/interfaces/index.js.map +0 -1
- package/lib/module/infraestructure/services/bridgefy_service.js +0 -2
- package/lib/module/infraestructure/services/bridgefy_service.js.map +0 -1
- package/lib/module/infraestructure/services/index.js +0 -2
- package/lib/module/infraestructure/services/index.js.map +0 -1
- package/lib/typescript/index.d.ts +0 -219
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/index.d.ts +0 -3
- package/lib/typescript/infraestructure/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/interfaces/ibridgefy.d.ts +0 -10
- package/lib/typescript/infraestructure/interfaces/ibridgefy.d.ts.map +0 -1
- package/lib/typescript/infraestructure/interfaces/index.d.ts +0 -2
- package/lib/typescript/infraestructure/interfaces/index.d.ts.map +0 -1
- package/lib/typescript/infraestructure/services/bridgefy_service.d.ts +0 -17
- package/lib/typescript/infraestructure/services/bridgefy_service.d.ts.map +0 -1
- package/lib/typescript/infraestructure/services/index.d.ts +0 -2
- package/lib/typescript/infraestructure/services/index.d.ts.map +0 -1
- package/src/infraestructure/index.tsx +0 -2
- package/src/infraestructure/interfaces/ibridgefy.tsx +0 -10
- package/src/infraestructure/interfaces/index.tsx +0 -1
- package/src/infraestructure/services/bridgefy_service.tsx +0 -20
- package/src/infraestructure/services/index.tsx +0 -1
package/README.md
CHANGED
|
@@ -1,185 +1,655 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
|
|
2
|
+
<img src="example/assets/bridgefylogo1.svg" width="512"/>
|
|
3
3
|
</p>
|
|
4
|
-
|
|
5
4
|
<p align="center">
|
|
6
|
-
|
|
5
|
+
<img src="example/assets/usecasemain.png" width="256"/>
|
|
7
6
|
</p>
|
|
8
7
|
|
|
9
8
|
# Bridgefy React Native SDK
|
|
9
|
+
|
|
10
10
|

|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
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.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
The **Bridgefy Software Development Kit (SDK)** is a state‑of‑the‑art plug‑and‑play solution that enables offline communication in your mobile apps by using Bluetooth mesh networks.
|
|
15
|
+
|
|
16
|
+
Integrate the Bridgefy SDK into your Android and iOS app to reach users who don't always have a reliable Internet connection and keep engagement high even in challenging environments.
|
|
17
|
+
|
|
18
|
+
**Website:** [https://bridgefy.me/sdk](https://bridgefy.me/sdk)
|
|
19
|
+
|
|
20
|
+
**Email:** [contact@bridgefy.me](mailto:contact@bridgefy.me)
|
|
21
|
+
|
|
22
|
+
**Twitter:** [https://twitter.com/bridgefy](https://twitter.com/bridgefy)
|
|
23
|
+
|
|
24
|
+
**Facebook:** [https://www.facebook.com/bridgefy](https://www.facebook.com/bridgefy)
|
|
16
25
|
|
|
17
|
-
|
|
18
|
-
**Email**. contact@bridgefy.me <br>
|
|
19
|
-
**witter**. https://twitter.com/bridgefy <br>
|
|
20
|
-
**Facebook**. https://www.facebook.com/bridgefy <br>
|
|
26
|
+
***
|
|
21
27
|
|
|
22
28
|
## Operation mode
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
Bridgefy automatically manages device discovery and connections to create a **mesh network**, whose size depends on the number of nearby devices and environmental conditions.
|
|
31
|
+
This mesh allows messages to hop across multiple devices, letting nodes in the same cluster or in different clusters exchange data without Internet access.
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="https://images.saymedia-content.com/.image/t_share/MTkzOTUzODU0MDkyNjE3MjIx/particlesjs-examples.gif" width="70%">
|
|
34
|
+
</p>
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
***
|
|
29
37
|
|
|
30
38
|
## Platform permissions
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
individual platform (iOS and Android) first. You can read more about each platform's requirements
|
|
34
|
-
below:
|
|
40
|
+
Before using the SDK in a React Native app, configure the required permissions at the native level for each platform.
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
- [iOS Permissions](https://github.com/bridgefy/sdk-ios#permissions)
|
|
43
|
+
- [Android Permissions](https://github.com/bridgefy/sdk-android#android-permissions)
|
|
44
|
+
|
|
45
|
+
***
|
|
38
46
|
|
|
39
47
|
## Installation
|
|
40
48
|
|
|
49
|
+
1. Add the Bridgefy React Native package to your project:
|
|
50
|
+
|
|
41
51
|
```bash
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
|
|
53
|
+
npm i bridgefy-react-native
|
|
54
|
+
# or
|
|
55
|
+
yarn add bridgefy-react-native
|
|
56
|
+
|
|
45
57
|
```
|
|
46
58
|
|
|
59
|
+
2. Make sure you are using:
|
|
60
|
+
|
|
61
|
+
- Android Gradle Plugin with D8/desugaring enabled.
|
|
62
|
+
- Xcode 14+ for iOS builds.
|
|
63
|
+
|
|
64
|
+
***
|
|
65
|
+
|
|
47
66
|
## Usage
|
|
48
67
|
|
|
49
|
-
### Initialization
|
|
50
68
|
|
|
51
|
-
The `initialize` method initializes the Bridgefy SDK with the given API key and propagation profile.
|
|
52
|
-
We will configure event listeners later.
|
|
53
69
|
|
|
70
|
+
### Migration Guide: Legacy → TurboModule SDK
|
|
71
|
+
<details>
|
|
72
|
+
<summary>API changes, new features, and gotchas.</summary>
|
|
73
|
+
|
|
74
|
+
### Import & Instantiation
|
|
75
|
+
❌ Old
|
|
54
76
|
```typescript
|
|
55
|
-
import { Bridgefy
|
|
77
|
+
import { Bridgefy } from 'bridgefy-react-native';
|
|
78
|
+
const bridgefy = new Bridgefy();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
✅ New
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import Bridgefy from 'bridgefy-react-native'; // Singleton instance
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**New:** Use `Bridgefy` class (wraps EventEmitter + convenience methods).
|
|
88
|
+
|
|
89
|
+
### Initialization
|
|
56
90
|
|
|
91
|
+
❌ Old
|
|
92
|
+
```typescript
|
|
93
|
+
import { Bridgefy } from 'bridgefy-react-native';
|
|
57
94
|
const bridgefy = new Bridgefy();
|
|
95
|
+
await bridgefy.initialize(apiKey, verboseLogging);
|
|
96
|
+
```
|
|
97
|
+
✅ New (Added operationMode)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import Bridgefy, { BridgefyOperationMode } from 'bridgefy-react-native';
|
|
101
|
+
|
|
102
|
+
await Bridgefy.initialize(apiKey, verboseLogging, BridgefyOperationMode.HYBRID);
|
|
103
|
+
```
|
|
104
|
+
**New:** `operationMode?: BridgefyOperationMode` (FOREGROUND/BACKGROUND/HYBRID).
|
|
105
|
+
|
|
106
|
+
### Propagation Profiles
|
|
107
|
+
|
|
108
|
+
❌ Old (Missing realtime)
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
export enum BridgefyPropagationProfile {
|
|
112
|
+
standard = 'standard',
|
|
113
|
+
highDensityNetwork = 'highDensityNetwork', // Note: different name
|
|
114
|
+
sparseNetwork = 'sparseNetwork',
|
|
115
|
+
longReach = 'longReach',
|
|
116
|
+
shortReach = 'shortReach',
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
✅ New (Added Realtime, renamed)
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import Bridgefy, { BridgefyPropagationProfile } from 'bridgefy-react-native';
|
|
124
|
+
|
|
125
|
+
await Bridgefy.start(userId, BridgefyPropagationProfile.REALTIME); // New!
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
**Mapping:**
|
|
129
|
+
|
|
130
|
+
| Old | New |
|
|
131
|
+
| ------------------ | -------------------- |
|
|
132
|
+
| highDensityNetwork | HIGH_DENSITY_NETWORK |
|
|
133
|
+
| Others match | + REALTIME |
|
|
134
|
+
|
|
135
|
+
### Error Handling
|
|
136
|
+
|
|
137
|
+
❌ Old (String enums)
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
export enum BridgefyErrorType {
|
|
141
|
+
simulatorIsNotSupported = 'simulatorIsNotSupported',
|
|
142
|
+
// Many iOS/Android-specific
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
✅ New (Unified codes)
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import Bridgefy, { BridgefyErrorCode, type BridgefyError } from 'bridgefy-react-native';
|
|
150
|
+
|
|
151
|
+
onFailToStart((error: BridgefyError) => {
|
|
152
|
+
if (error.code === BridgefyErrorCode.SERVICE_NOT_STARTED) { /* handle */ }
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
**New:** `BridgefyError = { code: BridgefyErrorCode, message: string, ... }` – consolidated codes.
|
|
157
|
+
|
|
158
|
+
### Events (Biggest Change!)
|
|
159
|
+
|
|
160
|
+
❌ Old (Manual EventEmitter)
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { NativeEventEmitter } from 'react-native';
|
|
164
|
+
const emitter = new NativeEventEmitter(BridgefyReactNative);
|
|
165
|
+
|
|
166
|
+
emitter.addListener(BridgefyEvents.bridgefyDidStart, handler);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
✅ New (Typed helpers + full coverage)
|
|
170
|
+
```typescript
|
|
171
|
+
import Bridgefy from 'bridgefy-react-native';
|
|
172
|
+
// Convenience methods (recommended)
|
|
173
|
+
Bridgefy.onStart((event) => console.log(event.userId));
|
|
174
|
+
Bridgefy.onReceiveData((event) => console.log(event.data));
|
|
175
|
+
|
|
176
|
+
// Full list (17+ events vs old 9)
|
|
177
|
+
Bridgefy.onConnectedPeers(({ peers }) => updatePeers(peers));
|
|
178
|
+
Bridgefy.onSendDataProgress(({ position, of }) => updateProgress(position / of));
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**New events:** `DID_UPDATE_CONNECTED_PEERS`, `SEND_DATA_PROGRESS`, operation mode.
|
|
182
|
+
|
|
183
|
+
**Cleanup:**
|
|
184
|
+
```typescript
|
|
185
|
+
sub.remove(); // All helpers return { remove }
|
|
186
|
+
Bridgefy.removeAllListeners(); // Clears everything
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Send Messages
|
|
190
|
+
❌ Old (Always required uuid)
|
|
191
|
+
```typescript
|
|
192
|
+
await BridgefyReactNative.send(data, { type: 'broadcast', uuid: '...' });
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
✅ New (Convenience + optional uuid)
|
|
196
|
+
```typescript
|
|
197
|
+
import Bridgefy from 'bridgefy-react-native';
|
|
198
|
+
|
|
199
|
+
// Broadcast (auto-generates uuid)
|
|
200
|
+
await Bridgefy.sendBroadcast('Hello all');
|
|
201
|
+
|
|
202
|
+
// P2P/Mesh (shorthand)
|
|
203
|
+
await Bridgefy.sendP2P('Hi!', 'recipient-id');
|
|
204
|
+
await Bridgefy.sendMesh('Through mesh', 'recipient-id');
|
|
205
|
+
|
|
206
|
+
// Raw (uuid optional for broadcast)
|
|
207
|
+
await Bridgefy.send(data, { type: BridgefyTransmissionModeType.BROADCAST });
|
|
208
|
+
```
|
|
209
|
+
**Returns:** `Promise<string>` (messageId)
|
|
210
|
+
|
|
211
|
+
### New Methods (Must‑use)
|
|
212
|
+
```typescript
|
|
213
|
+
import Bridgefy from 'bridgefy-react-native';
|
|
214
|
+
|
|
215
|
+
// Operation mode (BACKGROUND/HYBRID!)
|
|
216
|
+
await Bridgefy.setOperationMode({ mode: BridgefyOperationMode.HYBRID });
|
|
217
|
+
const status = await Bridgefy.getOperationStatus(); // { shouldRunInService, debugInfo }
|
|
218
|
+
|
|
219
|
+
// Background/foreground switches
|
|
220
|
+
await Bridgefy.switchToBackground();
|
|
221
|
+
|
|
222
|
+
// Connected peers array (vs old object?)
|
|
223
|
+
const peers = await Bridgefy.connectedPeers(); // string[]
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Breaking Changes Summary
|
|
228
|
+
|
|
229
|
+
| Area | Old | New |
|
|
230
|
+
| ------- | ------------------ | --------------------------- |
|
|
231
|
+
| Events | 9 manual | 17+ typed helpers |
|
|
232
|
+
| Profile | 5 (no realtime) | 6 (+REALTIME) |
|
|
233
|
+
| Error | String enums | BridgefyError objects |
|
|
234
|
+
| Send | Manual uuid always | Convenience + optional uuid |
|
|
235
|
+
| Init | 2 params | 3 params (+mode) |
|
|
236
|
+
| Peers | Object? | string[] |
|
|
237
|
+
| License | Date object | Timestamp number |
|
|
238
|
+
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
***
|
|
242
|
+
|
|
243
|
+
### Initialization
|
|
244
|
+
|
|
245
|
+
Use `initialize` to configure the Bridgefy SDK with your API key and base options.
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
|
|
249
|
+
import Bridgefy, {
|
|
250
|
+
BridgefyOperationMode,
|
|
251
|
+
} from 'bridgefy-react-native';
|
|
58
252
|
|
|
59
253
|
export default function App() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
254
|
+
React.useEffect(() => {
|
|
255
|
+
// Example: initialize & start
|
|
256
|
+
Bridgefy.initialize(
|
|
257
|
+
'YOUR_API_KEY', // UUID - Your Bridgefy license key.
|
|
258
|
+
true, // Enables or disables verbose logs.
|
|
259
|
+
BridgefyOperationMode.FOREGROUND // foreground | background | hybrid
|
|
260
|
+
).catch((error) => {
|
|
261
|
+
console.error(error);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
}, []);
|
|
70
265
|
}
|
|
71
266
|
```
|
|
267
|
+
- **apiKey:** Provided by Bridgefy developer site.
|
|
268
|
+
- **verboseLogging:** `true` for debugging.
|
|
269
|
+
- **operationMode:** `FOREGROUND`, `BACKGROUND`, or `HYBRID`.
|
|
270
|
+
|
|
271
|
+
### Starting and stopping the SDK
|
|
72
272
|
|
|
73
|
-
Once initialized, you can
|
|
273
|
+
Once initialized, you can start or stop the SDK as needed.
|
|
74
274
|
|
|
75
275
|
```typescript
|
|
276
|
+
import Bridgefy, {
|
|
277
|
+
BridgefyPropagationProfile,
|
|
278
|
+
} from 'bridgefy-react-native';
|
|
76
279
|
/**
|
|
77
280
|
* Start Bridgefy SDK operations
|
|
78
281
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
282
|
+
Bridgefy.start(
|
|
283
|
+
'your-user-id', // Optional UUID - Custom user identifier in the network.
|
|
284
|
+
BridgefyPropagationProfile.REALTIME // Optional BridgefyPropagationProfile - Message propagation profile.
|
|
82
285
|
);
|
|
286
|
+
```
|
|
287
|
+
- **userId:** Optional session uuid.
|
|
288
|
+
- **propagationProfile:** how messages travel through the mesh network. Choose the best fit for your use case.
|
|
83
289
|
|
|
290
|
+
```typescript
|
|
84
291
|
/**
|
|
85
292
|
* Stop Bridgefy SDK operations
|
|
86
293
|
*/
|
|
87
|
-
|
|
294
|
+
Bridgefy.stop();
|
|
88
295
|
```
|
|
89
296
|
|
|
90
|
-
|
|
297
|
+
***
|
|
298
|
+
|
|
299
|
+
## Sending data
|
|
91
300
|
|
|
92
|
-
|
|
93
|
-
identify the message that was sent. You'll need to serialize your data into a `string` before
|
|
94
|
-
transmission so React Native can communicate the information to the native platform.
|
|
301
|
+
Under the hood, these call `send(data, transmissionMode)` with the proper `BridgefyTransmissionModeType`.
|
|
95
302
|
|
|
96
303
|
```typescript
|
|
304
|
+
import Bridgefy from 'bridgefy-react-native';
|
|
305
|
+
|
|
97
306
|
async function sendData() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
307
|
+
|
|
308
|
+
// Broadcast
|
|
309
|
+
const lastBroadcastMessageId = await Bridgefy.sendBroadcast(JSON.stringify({ text: 'Hello everyone' }));
|
|
310
|
+
|
|
311
|
+
// P2P
|
|
312
|
+
const lastP2PMessageId = await Bridgefy.sendP2P(JSON.stringify({ text: 'Hello peer' }), 'recipient-user-id');
|
|
313
|
+
|
|
314
|
+
// Mesh
|
|
315
|
+
const lastMeshMessageId = await Bridgefy.sendMesh(JSON.stringify({ text: 'Through mesh' }), 'recipient-user-id');
|
|
316
|
+
|
|
106
317
|
}
|
|
107
318
|
```
|
|
108
319
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
console.log(`Bridgefy received data`, event);
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
return () => {
|
|
138
|
-
for (const sub of subscriptions) {
|
|
139
|
-
sub.remove();
|
|
140
|
-
}
|
|
141
|
-
};
|
|
320
|
+
The method returns a message UUID you can use for tracking or acknowledgement flows.
|
|
321
|
+
|
|
322
|
+
***
|
|
323
|
+
|
|
324
|
+
## Handling SDK events
|
|
325
|
+
|
|
326
|
+
Bridgefy provides a comprehensive event system via React Native's `NativeEventEmitter`,
|
|
327
|
+
with typed helper methods on the `Bridgefy` class for easy listening.
|
|
328
|
+
All events are defined in the `BridgefyEvents` enum and emit from the native Module.
|
|
329
|
+
|
|
330
|
+
### Event Listening Basics
|
|
331
|
+
Use `addEventListener(eventName, listener)` for any event, or the typed helpers like `onStart(listener)`.
|
|
332
|
+
Each returns `{ remove: () => void }` for cleanup. Always call `remove()` or `removeAllListeners()` to prevent leaks, especially in components.
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
```typescript
|
|
336
|
+
|
|
337
|
+
import Bridgefy,
|
|
338
|
+
{ BridgefyEvents }
|
|
339
|
+
from 'bridgefy-react-native';
|
|
340
|
+
|
|
341
|
+
// Generic listener
|
|
342
|
+
const sub = Bridgefy.addEventListener(BridgefyEvents.BRIDGEFY_DID_START, (event) => {
|
|
343
|
+
console.log(event);
|
|
142
344
|
});
|
|
345
|
+
sub.remove(); // Clean up
|
|
346
|
+
|
|
347
|
+
// Helper (preferred)
|
|
348
|
+
const subHelper = Bridgefy.onStart((event) => console.log(event.userId));
|
|
349
|
+
subHelper.remove();
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
### Lifecycle Events
|
|
353
|
+
|
|
354
|
+
These track SDK start/stop/destroy operations.
|
|
355
|
+
|
|
356
|
+
- `onStart(listener: (event: BridgefyStartEvent) => void)` → `BRIDGEFY_DID_START`
|
|
357
|
+
|
|
358
|
+
- Fires when SDK starts successfully.
|
|
359
|
+
- Payload: `{ userId: string }` (your assigned UUID).
|
|
360
|
+
|
|
361
|
+
- `onStop(listener: () => void)` → `BRIDGEFY_DID_STOP`
|
|
362
|
+
- SDK stopped cleanly.
|
|
363
|
+
|
|
364
|
+
- `onFailToStart(listener: (error: BridgefyError) => void)` → `BRIDGEFY_DID_FAIL_TO_START`
|
|
365
|
+
- Start failed (e.g., permissions, Bluetooth off).
|
|
366
|
+
- Payload: `BridgefyError` with `code` like `BLUETOOTH_DISABLED`.
|
|
367
|
+
|
|
368
|
+
- `onFailToStop(listener: (error: BridgefyError) => void)` → `BRIDGEFY_DID_FAIL_TO_STOP`
|
|
369
|
+
- Stop operation failed.
|
|
370
|
+
|
|
371
|
+
- `BRIDGEFY_DID_DESTROY_SESSION` / `BRIDGEFY_DID_FAIL_TO_DESTROY_SESSION`
|
|
372
|
+
- Session destroyed or failed (use generic addEventListener).
|
|
373
|
+
|
|
374
|
+
### Connection Events
|
|
375
|
+
Monitor peer connections and network changes.
|
|
376
|
+
|
|
377
|
+
- `onConnect(listener: (event: BridgefyConnectEvent) => void)` → `BRIDGEFY_DID_CONNECT`
|
|
378
|
+
- New peer connected.
|
|
379
|
+
- Payload: `{ userId: string }`.
|
|
380
|
+
|
|
381
|
+
- `onConnectedPeers(listener: (event: BridgefyUpdatedConnectedEvent) => void)` → `BRIDGEFY_DID_UPDATE_CONNECTED_PEERS`
|
|
382
|
+
- Peers list updated (add/remove).
|
|
383
|
+
- Payload: `{ peers: string[] }` (array of user UUIDs).
|
|
384
|
+
|
|
385
|
+
- `onDisconnect(listener: (event: BridgefyDisconnectEvent) => void)` → `BRIDGEFY_DID_DISCONNECT`
|
|
386
|
+
- Peer disconnected.
|
|
387
|
+
- Payload: `{ userId: string }`.
|
|
388
|
+
|
|
389
|
+
### Secure Connection Events
|
|
390
|
+
For encrypted P2P/mesh communication.
|
|
391
|
+
- `onEstablishSecureConnection(listener: (event: BridgefySecureConnectionEvent) => void)` → `BRIDGEFY_DID_ESTABLISH_SECURE_CONNECTION`
|
|
392
|
+
- Secure link ready.
|
|
393
|
+
- Payload: `{ userId: string }`.
|
|
394
|
+
|
|
395
|
+
- `onFailToEstablishSecureConnection(listener: (error: BridgefyError & { userId: string }) => void)` → `BRIDGEFY_DID_FAIL_TO_ESTABLISH_SECURE_CONNECTION`
|
|
396
|
+
- Secure setup failed (e.g., timeout).
|
|
397
|
+
- Payload: BridgefyError + { userId: string }.
|
|
398
|
+
|
|
399
|
+
### Message Events
|
|
400
|
+
Track send/receive progress and failures.
|
|
401
|
+
|
|
402
|
+
- `onSendMessage(listener: (event: BridgefySendMessageEvent) => void)` → `BRIDGEFY_DID_SEND_MESSAGE`
|
|
403
|
+
- Message sent successfully.
|
|
404
|
+
- Payload: '{ messageId: string }` (UUID).
|
|
405
|
+
|
|
406
|
+
- `onSendDataProgress(listener: (event: BridgefyDidSendDataProgress) => void)` → `BRIDGEFY_DID_SEND_DATA_PROGRESS`
|
|
407
|
+
- Transfer progress (useful for large payloads).
|
|
408
|
+
- Payload: `{ messageId: string, position: number, of: number }`.
|
|
409
|
+
|
|
410
|
+
- `onFailSendingMessage(listener: (error: BridgefyError & { messageId: string }) => void)` → `BRIDGEFY_DID_FAIL_SENDING_MESSAGE`
|
|
411
|
+
- Send failed (e.g., no path).
|
|
412
|
+
- Payload: `BridgefyError` + `{ messageId: string }`.
|
|
413
|
+
|
|
414
|
+
- `onReceiveData(listener: (event: BridgefyReceiveDataEvent) => void)` → `BRIDGEFY_DID_RECEIVE_DATA`
|
|
415
|
+
- Data received.
|
|
416
|
+
- Payload: `{ data: string, messageId: string, transmissionMode: BridgefyTransmissionMode }`.
|
|
417
|
+
|
|
418
|
+
- `BRIDGEFY_MESSAGE_RECEIVED`
|
|
419
|
+
- Legacy message event (use generic listener).
|
|
420
|
+
|
|
421
|
+
### License events (removed)
|
|
422
|
+
|
|
423
|
+
License events have been removed from the latest Bridgefy React Native SDK and are no longer emitted at runtime. If you previously used `onUpdateLicense` or `onFailToUpdateLicense`, you can safely delete those listeners; license validation now runs internally.
|
|
424
|
+
|
|
425
|
+
***
|
|
426
|
+
|
|
427
|
+
## Additional functionality
|
|
428
|
+
|
|
429
|
+
The `Bridgefy` class exposes several helper methods to manage sessions, connectivity, and licensing.
|
|
430
|
+
|
|
431
|
+
- `destroySession()`: Destroys the current SDK session and cleans local state.
|
|
432
|
+
- `establishSecureConnection(userId: string): Promise<void>`: Establishes an end-to-end encrypted connection with the specified peer.
|
|
433
|
+
- `currentUserId(): Promise<string>`: Returns the current device's user identifier.
|
|
434
|
+
- `connectedPeers(): Promise<string[]>`: Returns the list of currently connected peers.
|
|
435
|
+
- `licenseExpirationDate(): Promise<number>`: Returns the configured license expiration timestamp (milliseconds since epoch).
|
|
436
|
+
- `updateLicense(): Promise<void>`: Deprecated: License updates are handled automatically; this method is preserved only for backwards compatibility and will be removed in a future release.
|
|
437
|
+
- `isInitialized(): Promise<boolean>`: Indicates whether the SDK has been initialized.
|
|
438
|
+
- `isStarted(): Promise<boolean>`: Indicates whether the SDK is currently running.
|
|
439
|
+
|
|
440
|
+
### Operation mode control
|
|
441
|
+
|
|
442
|
+
Bridgefy's runs in relation to your app's lifecycle,
|
|
443
|
+
balancing battery efficiency, reliability, and background connectivity.
|
|
444
|
+
They are defined in the `BridgefyOperationMode` enum and set during `initialize` or runtime.
|
|
445
|
+
|
|
446
|
+
**FOREGROUND Mode**
|
|
447
|
+
|
|
448
|
+
SDK runs **only when your app is in the foreground**.
|
|
449
|
+
- **Key traits:**
|
|
450
|
+
- No background service needed.
|
|
451
|
+
- Stops BLE scanning/mesh when app backgrounds (e.g., user switches apps).
|
|
452
|
+
- Lowest battery impact.
|
|
453
|
+
|
|
454
|
+
- **Best for:** Testing, development, or foreground-only apps like games.
|
|
455
|
+
- **Trade-offs:** No connectivity when backgrounded; simple setup (no Android manifest changes).
|
|
456
|
+
|
|
457
|
+
**BACKGROUND Mode**
|
|
458
|
+
|
|
459
|
+
SDK runs **continuously in a foreground service**, even when app is backgrounded or killed.
|
|
460
|
+
- **Key traits:**
|
|
461
|
+
- Persistent mesh networking.
|
|
462
|
+
- Shows persistent notification (Android requirement for foreground services).
|
|
463
|
+
- Higher battery drain due to constant BLE.
|
|
464
|
+
|
|
465
|
+
- **Best for:** Always-on messaging apps needing 24/7 mesh.
|
|
466
|
+
- **Trade-offs:** Requires Android service declaration + FOREGROUND_SERVICE permission; visible notification; more battery use.
|
|
467
|
+
|
|
468
|
+
**HYBRID Mode**
|
|
469
|
+
|
|
470
|
+
**Adaptive mode** that switches automatically: foreground when app active, background service when backgrounded.
|
|
471
|
+
|
|
472
|
+
- **Key traits:**
|
|
473
|
+
- Starts in foreground (efficient when visible).
|
|
474
|
+
- Auto-switches to service on background (maintains connectivity).
|
|
475
|
+
- Uses switchToBackground() / switchToForeground() under the hood.
|
|
476
|
+
|
|
477
|
+
- **Best for:** Most production apps – balances UX, battery, and reliability.
|
|
478
|
+
- **Trade-offs:** Needs both foreground and service setup; seamless transitions.
|
|
479
|
+
|
|
480
|
+
### API Usage
|
|
481
|
+
Set mode at init or runtime (after `initialize`).
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
|
|
485
|
+
import Bridgefy, {
|
|
486
|
+
BridgefyOperationMode,
|
|
487
|
+
} from 'bridgefy-react-native';
|
|
488
|
+
|
|
489
|
+
import { BridgefyOperationMode } from 'bridgefy-react-native';
|
|
490
|
+
|
|
491
|
+
// At initialization (recommended)
|
|
492
|
+
await Bridgefy.initialize('YOUR_KEY', false, BridgefyOperationMode.HYBRID);
|
|
493
|
+
|
|
494
|
+
// Runtime change
|
|
495
|
+
await Bridgefy.setOperationMode({ mode: BridgefyOperationMode.BACKGROUND });
|
|
496
|
+
|
|
497
|
+
// Check current
|
|
498
|
+
const mode = await Bridgefy.getOperationMode(); // Returns 'foreground' | 'background' | 'hybrid'
|
|
499
|
+
|
|
500
|
+
// Full status
|
|
501
|
+
const status = await Bridgefy.getOperationStatus();
|
|
502
|
+
// Returns: { operationMode, isInitialized, isStarted, shouldRunInService, debugInfo }
|
|
503
|
+
|
|
504
|
+
// Manual switches (for HYBRID)
|
|
505
|
+
await Bridgefy.switchToBackground();
|
|
506
|
+
await Bridgefy.switchToForeground();
|
|
507
|
+
|
|
508
|
+
```
|
|
509
|
+
Type: `BridgefyOperationModeConfig = { mode: BridgefyOperationMode };` `BridgefyOperationModeStatus` includes service flags.
|
|
510
|
+
|
|
511
|
+
### Setup Notes
|
|
512
|
+
|
|
513
|
+
**iOS Security imposes several limitations on applications participating in communication sessions when the app is not on the active screen.**
|
|
514
|
+
|
|
515
|
+
- **Android:** BACKGROUND/HYBRID need `<service android:foregroundServiceType="dataSync" />` and permissions.
|
|
516
|
+
- **Recommendation:** Start with HYBRID for production; use getOperationStatus() to debug service issues.
|
|
517
|
+
|
|
518
|
+
***
|
|
519
|
+
|
|
520
|
+
## Bridgefy propagation profiles
|
|
521
|
+
|
|
522
|
+
The `BridgefyPropagationProfile` optimize mesh networking for different environments by tuning **hops, TTL, sharing time, propagation limits, and tracking**.
|
|
523
|
+
Select during `start()` to match your use case.
|
|
524
|
+
|
|
525
|
+
### When to Use Each
|
|
526
|
+
|
|
527
|
+
- `STANDARD`: Balanced default profile for general messaging.
|
|
528
|
+
- `HIGH_DENSITY_NETWORK`: Optimized for crowded environments such as concerts or stadiums.
|
|
529
|
+
- `SPARSE_NETWORK`: Suitable for rural or low-density areas.
|
|
530
|
+
- `LONG_REACH`: Prioritizes maximum distance, useful for emergencies or outdoor activities.
|
|
531
|
+
- `SHORT_REACH`: Focuses on nearby devices only.
|
|
532
|
+
- `REALTIME`: Prioritizes ultra-low latency for time-sensitive notifications.
|
|
533
|
+
|
|
534
|
+
***
|
|
535
|
+
|
|
536
|
+
## Common Errors
|
|
537
|
+
|
|
538
|
+
### Android
|
|
539
|
+
<details>
|
|
540
|
+
<summary>Gradle & D8 / Desugar Requirements</summary>
|
|
541
|
+
|
|
542
|
+
Bridgefy uses modern Java APIs and requires *D8 and core library desugaring* to be enabled.
|
|
543
|
+
|
|
544
|
+
In your root `android/build.gradle` (or `settings.gradle` + new AGP configuration), ensure:
|
|
545
|
+
|
|
546
|
+
- Android Gradle Plugin version supports desugaring (AGP 7+ recommended).
|
|
547
|
+
- Java 8+ compatibility and core library desugaring are enabled in app module.
|
|
548
|
+
|
|
549
|
+
In `android/app/build.gradle`:
|
|
550
|
+
```groovy
|
|
551
|
+
android {
|
|
552
|
+
compileSdkVersion 34
|
|
553
|
+
|
|
554
|
+
defaultConfig {
|
|
555
|
+
minSdkVersion 23
|
|
556
|
+
targetSdkVersion 34
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
compileOptions {
|
|
560
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
561
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
562
|
+
coreLibraryDesugaringEnabled true // Enable desugaring
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
dependencies {
|
|
567
|
+
// Required for desugaring
|
|
568
|
+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
This avoids “Default interface methods” and time API issues at runtime.
|
|
574
|
+
|
|
575
|
+
</details>
|
|
576
|
+
|
|
577
|
+
<details>
|
|
578
|
+
<summary>Android Service (Background / Hybrid Modes)</summary>
|
|
579
|
+
|
|
580
|
+
When using **BACKGROUND** or **HYBRID** `BridgefyOperationMode`, Bridgefy should run in a foreground service so it keeps the mesh active while your app is in the background.
|
|
581
|
+
|
|
582
|
+
1. Declare the service in `AndroidManifest.xml`:
|
|
583
|
+
```xml
|
|
584
|
+
<service
|
|
585
|
+
android:name="me.bridgefy.plugin.react_native.service.BridgefyService"
|
|
586
|
+
android:enabled="true"
|
|
587
|
+
android:exported="false"
|
|
588
|
+
android:foregroundServiceType="dataSync" />
|
|
589
|
+
|
|
143
590
|
```
|
|
591
|
+
2. Add required permissions:
|
|
592
|
+
|
|
593
|
+
```xml
|
|
594
|
+
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
595
|
+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
|
596
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
597
|
+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
598
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
599
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
600
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
601
|
+
|
|
602
|
+
```
|
|
603
|
+
Missing runtime permissions for BLE scanning.
|
|
604
|
+
|
|
605
|
+
**Fix**(Android 12+):
|
|
606
|
+
```xml
|
|
607
|
+
<!-- Manifest -->
|
|
608
|
+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
|
609
|
+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
610
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
144
611
|
|
|
145
|
-
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
3. At runtime, request the necessary Bluetooth and location permissions before starting the SDK.
|
|
615
|
+
|
|
616
|
+
</details>
|
|
617
|
+
<details>
|
|
618
|
+
<summary>FOREGROUND_SERVICE permission crash</summary>
|
|
619
|
+
|
|
620
|
+
**Cause:** Missing permission for Android 14+.
|
|
621
|
+
|
|
622
|
+
**Fix:** Add to AndroidManifest.xml:
|
|
623
|
+
```xml
|
|
624
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
|
625
|
+
```
|
|
146
626
|
|
|
147
|
-
|
|
148
|
-
The `Bridgefy` class also provides various functionalities:
|
|
627
|
+
**Bluetooth denied in background**
|
|
149
628
|
|
|
150
|
-
|
|
151
|
-
- `updateLicense()`: Update license.
|
|
152
|
-
- `establishSecureConnection(userId: string): Promise<void>`: Establish a secure connection with a specified user.
|
|
153
|
-
- `currentUserId(): Promise<string>`: Get the current user ID.
|
|
154
|
-
- `connectedPeers(): Promise<string[]>`: Get a list of connected peers.
|
|
155
|
-
- `licenseExpirationDate(): Promise<Date>`: Get the license expiration date.
|
|
156
|
-
- `isInitialized(): Promise<boolean>`: Check if the SDK is initialized.
|
|
157
|
-
- `isStarted(): Promise<boolean>`: Check if the SDK is started.
|
|
629
|
+
**Cause:** Android restricts BLE in background without foreground service.
|
|
158
630
|
|
|
159
|
-
|
|
631
|
+
**Fix:** Use BACKGROUND/HYBRID mode + service setup.
|
|
160
632
|
|
|
161
|
-
|
|
633
|
+
</details>
|
|
162
634
|
|
|
163
|
-
|
|
635
|
+
***
|
|
164
636
|
|
|
165
|
-
-
|
|
166
|
-
- `highDensityNetwork`: High-density network profile.
|
|
167
|
-
- `sparseNetwork`: Sparse network profile.
|
|
168
|
-
- `longReach`: Long-reach profile.
|
|
169
|
-
- `shortReach`: Short-reach profile.
|
|
637
|
+
## Multi-platform support
|
|
170
638
|
|
|
171
|
-
|
|
639
|
+
Bridgefy SDKs interoperate across platforms so iOS and Android devices can communicate seamlessly as long as they run a Bridgefy-enabled app.
|
|
172
640
|
|
|
641
|
+
- [Bridgefy iOS](https://github.com/bridgefy/sdk-ios)
|
|
642
|
+
- [Bridgefy Android](https://github.com/bridgefy/sdk-android)
|
|
173
643
|
|
|
644
|
+
***
|
|
174
645
|
|
|
175
|
-
##
|
|
646
|
+
## Contact & support
|
|
176
647
|
|
|
177
|
-
|
|
648
|
+
For commercial inquiries, technical questions, or integration help, reach out using the channels below.
|
|
178
649
|
|
|
179
|
-
|
|
180
|
-
|
|
650
|
+
- Email: [contact@bridgefy.me](mailto:contact@bridgefy.me)
|
|
651
|
+
- Website: [https://bridgefy.me/sdk](https://bridgefy.me/sdk)
|
|
181
652
|
|
|
182
|
-
|
|
183
|
-
+ contact@bridgefy.me
|
|
653
|
+
***
|
|
184
654
|
|
|
185
|
-
©
|
|
655
|
+
© 2026 Bridgefy Inc. All rights reserved.
|