Navigation
Quick start
This Quick Start guide will walk you through the steps to integrate Sabil into your app Swift. By the end of this guide, you will have a fully working account sharing mechanism integrated on your application.
Installation
The iOS SDK can be installed using Swift Package Manager. The easiest way to do that is to follow these steps:
- File > Add Packages ...
- Search for Sabil iOS SDK package using the github URL:
https://github.com/sabil-io/sabil-ios-sdk
- Make sure you set the minimum version to
2.0.0
and the rule toUp to Next Major Version
- Click on add package then add the
SabilSDK
from the list of products.
Import & Configure
- In your
AppDelegate
, import theSabilSDK
.import SabilSDKfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { // highlight-next-line Sabil.shared.config(clientID: <#your_client_id#>) // Required return true}func applicationWillEnterForeground(_ application: UIApplication) { // highlight-next-line Sabil.shared.attach()}
Usage
- As soon as the user's ID becomes available, let the Sabil SDK know about that and attach the device to that user ID.
Sabil.shared.setUserID(id) // RequiredSabil.shared.attach() // Required// Strongly recommended to implement this callback to logout the user// if they are exceed the limit for account sharing.Sabil.shared.onLogoutCurrentDevice = { usage in // TODO: logout the user here.}
- (Optional) If you are using the identity APIs, or you don't have the user ID (the user can perform actions while not logged in), use the
identify
function in place of the above code (step 6). Make sure you add the code from step 6 as soon as you have the user ID.Sabil.shared.identify() { deviceIdentity, err in if let err = err { print(err.message) } else if let deviceIdentity = deviceIdentity { print("Device identity: \(deviceIdentity.identity) with confidence: \(deviceIdentity.confidence * 100)%") }}
For more on identification, see identify
Improved accuracy
For improved accuracy, call the Sabil.shared.attach()
on every key view in your app.