OpenPass SDK for iOS quickstart guide
The iOS SDK helps you create an OpenPass client, which can be integrated with your website to implement single sign-on (SSO) for the open internet. With the help of this SDK, you can also integrate OpenPass directly with your iOS or iPadOS application.
After you have configured the SDK, you can handle the authentication response that is optimized for mobile or TV-based interfaces to sign in a user.
IMPORTANT: Before installation, be sure to sign up for an OpenPass account to get a client ID.
For details on integrating your OpenPass implementation with UID2, contact your Technical Account Manager at The Trade Desk.
Follow these steps to install the SDK:
- Install the SDK.
- Implement the SDK using the mobile web flow.
TIP: For debugging, enable additional logging.
The following sections detail each step.
Install the SDK
To install the SDK, use the Swift Package Manager tool and choose one of these distribution options:
- Directly in Xcode
- The app's
Package.swiftmanifest file
NOTE: You can modify the Swift Package Manager configuration in the
Package.swiftfile directly, but using the Xcode option may be easier because it provides a user interface for configuring this file.
The following is an example URL for an OpenPass Swift package.
dependencies [
.package(url: "https://github.com/openpass-sso/openpass-ios-sdk.git", .upToNextMajor(from: "1.0.0"))
]
Implement the SDK
To configure the SDK, you must do the following:
- Configure your app
- Follow Apple privacy requirements
- Initialize the OpenPass manager
- Implement the mobile web sign-in flow
- Sign out of the flow
Configure your app
To get up and running with OpenPass using the iOS SDK, follow these steps:
- Sign up for an OpenPass account to get a client ID.
- To configure the
Info.plistinformation property list for your app, add theOpenPassClientIdkey with the client ID from step 1 and theOpenPassRedirectHostfile with the redirect host.
Here's a screenshot showing the OpenPassClientId key and OpenPassRedirectHost file in Xcode.
Follow Apple privacy requirements
Implement any requirements from Apple regarding in-app privacy and app-store publishing. For details, see the following:
- App Tracking Transparency
- OpenPass Apple App Store Disclosure Guidance
Initialize the OpenPass Manager
The OpenPass manager is a singleton that automatically initializes the first time it is used.
TIP: Though not necessary, you can initialize the manager before your app uses it, such as during an app launch in the
AppDelegateclass. When the manager is initialized, it will perform a small amount of processing, such as reading or parsing the file from disk or storage. Some apps may want to control when this overhead happens rather than when it's actually being used. The following is a code example.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize OpenPassManager
_ = OpenPassManager.shared
}
Implement mobile web sign-in flow
The OpenPass login can be standalone, or you can add it to a list if you support other SSO providers such as Google, Facebook, and Apple.
The sign-in flow for iOS and iPadOS uses the Apple ASWebAuthenticationSession service to launch the sign-in experience. After the user has signed in, the web component redirects to the application with the necessary information.
After configuring your app, launch the sign-in flow using the OpenPassManager.shared.beginSignInUXFlow() method. The OpenPass manager will then detect when a user has signed in.
NOTE: As an option, the flow will also share token and error results, but you should obtain final OpenPass tokens directly from the OpenPass manager.
Here is an example of a flow launch.
Task(priority: .userInitiated) {
do {
try await OpenPassManager.shared.beginSignInUXFlow()
self.openPassTokens = OpenPassManager.shared.openPassTokens
} catch {
// Handle error thrown
}
}
Sign out of the flow
To sign the user out from OpenPass on the device, use the OpenPassManager.shared.signOut() method. It removes previously saved OpenPass tokens from the key chain and the OpenPassManager.shared.openPassTokens manager, and resets OpenPass to its original post-initialized state.
For more information, see the following pages:
- iOS API Reference
- tvOS Quickstart Guide
- UID2
- Integration best practices
- Co-branding guidelines