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.


The iOS SDK can be installed using Swift Package Manager. The easiest way to do that is to follow these steps:

  1. File > Add Packages ...
  2. Search for Sabil iOS SDK package using the github URL: package installation image
  3. Make sure you set the minimum version to 2.0.0 and the rule to Up to Next Major Version
  4. Click on add package then add the SabilSDK from the list of products.

Import & Configure

  1. In your AppDelegate, import the SabilSDK.
    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()}


  1. 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.}
  2. (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.