The init method initializes the Bridgefy SDK with an API key. The delegate parameter is required and should be an object that conforms to the BridgefyDelegate
protocol. The verboseLogging parameter is optional and enables more detailed logging if set to true.
The following code shows how to start the SDK (using your API key) and how to assign the delegate.
do {
bridgefy = try Bridgefy(withApiKey: apiKey,
delegate: BridgefyDelegate,
verboseLogging: Bool)
} catch {
// Handle the error
}
The string apiKey represents a valid API key. An Internet connection is needed, at least for the first time to validate the license. The delegate is the class that will implement all the delegate methods from the BridgefySDK.
After initializing the SDK, you should call the start()
function to have the SDK's services running.
bridgefy.start(withUserId: UUID?,
andPropagationProfile: PropagationProfile)
The optional UUID userId is the id that the SDK will use to identify the user. If a nil value is passed, the SDK will randomly assign a UUID. The propagationProfile value is the profile the SDK will use to propagate messages through the mesh.
Once the service is started, the following delegate function is called:
func bridgefyDidStart(with userId: UUID)
The userId is the id used to identify the current user/device in the BridgefySDK.
In the case an error occurs while starting the BridgefySDK, the following delegate function is called:
func bridgefyDidFailToStart(with error: BridgefyError)
enum PropagationProfile {
case standard
case highDensityNetwork
case sparseNetwork
case longReach
case shortReach
}
Profile | Hops limit | TTL(s) | Sharing Time | Maximum Propagation | Tracklist limit |
---|---|---|---|---|---|
Standard | 100 | 86400 (1 d) | 15000 | 200 | 50 |
High Density Environment | 50 | 3600 (1 h) | 10000 | 50 | 50 |
Sparse Environment | 100 | 302400 (3.5 d) | 10000 | 250 | 50 |
Long Reach | 250 | 604800 (7 d) | 15000 | 1000 | 50 |
Short Reach | 50 | 1800 | 10000 | 50 | 50 |
<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/08bcd78f-acea-4107-8e5c-cce45804142d/15271691-786a-41c7-8800-5547e5515794/Bridgefy_Official_Icon_2021.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/08bcd78f-acea-4107-8e5c-cce45804142d/15271691-786a-41c7-8800-5547e5515794/Bridgefy_Official_Icon_2021.png" width="40px" /> Hops limit: The maximum number of hops a message can get. Each time a message is forwarded, is considered a hop.
</aside>