Berkanan SDK enables Bluetooth mesh messaging between nearby apps. It's the framework used by [Berkanan Messenger](https://apps.apple.com/app/berkanan-messenger/id1289061820) ([Product Hunt](https://www.producthunt.com/posts/berkanan), [TechCrunch](https://techcrunch.com/2018/09/27/berkanan-is-a-bluetooth-powered-group-messaging-app/)) and [Berkanan Messenger Lite](https://apps.apple.com/app/berkanan-messenger-lite/id1479731429) ([GitHub](https://github.com/zssz/BerkananLite)).
The goal is to create a decentralized mesh network for the people, powered by their device's Bluetooth antenna. People could rely on this network for texting in situations, like emergencies, when there's no other connectivity available — it could literally save lives.
With Berkanan SDK, apps can discover nearby apps, which also have the SDK integrated and Bluetooth turned on, and send them small messages. The range for these messages is about 70 meters, but they can reach further because the SDK automatically resends them upon receiving. The more apps use Berkanan SDK, the further the reach of the messages gets.
- Background: On iOS, it works even while in the background. However, background-running apps can't discover each other — the system enforces this policy.
- Connectionless communication with no pairing, no sessions, and no limit on the number of apps.
- For sending messages, the SDK uses [flooding](https://en.wikipedia.org/wiki/Flooding_(computer_networking)), where duplicates are filtered by tracking their identifiers and decreasing their time to live (TTL) by 1, until they reach 0, as they travel from app to app.
- No built-in support for encryption, [acknowledgment](https://en.wikipedia.org/wiki/Acknowledgement_(data_networks)), or [store and forward](https://en.wikipedia.org/wiki/Store_and_forward). You have to roll your own if your use case requires it.
Select your app target and then go to `Editor` / `Add Capability` / `Background Modes`. Check both `Uses Bluetooth LE accessories` and `Acts as a Bluetooth LE accessory`.
Go to `Signing & Capabilities` / `App Sandbox` and check the `Bluetooth` checkbox.
Add `NSBluetoothAlwaysUsageDescription` and `NSBluetoothPeripheralUsageDescription` to the Info.plist with the value:
> Allow access to the Berkanan Bluetooth Service to be able to communicate even while offline.
#### Adding Berkanan SDK to your app
Go to `File` / `Swift Packages` / `Add Package Dependency...` and enter `https://github.com/zssz/BerkananSDK.git`
Add `@import BerkananSDK` to your source files where needed.
#### Using Berkanan SDK in your app
##### Initializing a local service with a configuration to advertise
```swift
let configuration = Configuration(
// The identifier is used to identify what kind of configuration the service has.
To see how [Berkanan Messenger Lite app](https://apps.apple.com/app/berkanan-messenger-lite/id1479731429) integrates Berkanan SDK, check out its [source code](https://github.com/zssz/BerkananLite).