Navigation
iOS
This quick start guide will walk you through the steps to integrate Rupt into your app Swift. By the end of this guide, you will have a fully working account sharing mechanism integrated on your application.
Step 1: Installation
- Download the Rupt SDK binary from this link
- Unzip & drag and drop the
Rupt.xcframework
into your project. - Select
Copy items if needed
and clickFinish
.
Step 2: Usage
You can integrate Rupt into your app in two ways:
Option 1: Using ViewControllers or Storyboards
- In your
AppDelegate
, import theRupt
SDK and initialize it with yourclientID
anduseViewController
set totrue
.class AppDelegate: UIResponder, UIApplicationDelegate { private let rupt = Rupt(clientID: "xxxxx-xxx-xxxx-xxxx-xxxxxxx", useViewController: true) }
replacexxxxx-xxx-xxxx-xxxx-xxxxxxx
with yourclientID
. - In your
AppDelegate
, set theuserID
and attach the device to the user in thedidFinishLaunchingWithOptions
method.func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { rupt.setUserID("<#user_id#>") rupt.attach() return true }
Option 2: Using SwiftUI
- In your top
ContentView
, import theRupt
SDK and initialize it with yourclientID
anduseViewController
set tofalse
or leave it out as it defaults tofalse
.struct ContentView: View { private let rupt = Rupt(clientID: "xxxxx-xxx-xxxx-xxxx-xxxxxxx", useViewController: false) }
replacexxxxx-xxx-xxxx-xxxx-xxxxxxx
with yourclientID
. - In your
ContentView
, set theuserID
and attach the device to the user in theinit
oronAppear
method.struct ContentView: View { private let rupt = Rupt(clientID: "xxxxx-xxx-xxxx-xxxx-xxxxxxx", useViewController: false) init() { rupt.setUserID("<#user_id#>") rupt.attach() } }
Step 3: Handle callbacks
If Rupt determines that the user is sharing their account, and you have the Account sharing protection
setting enabled, the user will see a challenge to verify they own this account, logout, or create a new account (i.e. stop sharing). Rupt will handle the verification, but you need to handle the logout and account creation.
In your ViewController or SwiftUI View:
rupt.onLogoutCurrentDevice = {
//TODO: log the user out of this device
}
rupt.onCreateNewAccount = {
//TODO: logout the current account and guide the user to create a new account
}