Мы используем cookie-файлы
Хорошо

Freedom ID SDK iOS

Introduction
Welcome to the Freedom ID SDK integration guide! This guide will help you smoothly integrate the Freedom ID SDK into your iOS app, enabling secure authentication and user data permission management within the Freedom Holding ecosystem. Freedom ID serves as a single point of entry for users, ensuring top-level security and privacy while managing data permissions and accessing multiple services.
The Freedom ID SDK is available for both Android (API level 24 and above) and iOS (12 and above) platforms. This guide specifically covers the iOS platform. Let’s get started! 🚀
Getting Started
Prerequisites
Before you begin integrating the Freedom ID SDK into your iOS app, ensure you have the following:
  • An iOS app project with a minimum iOS 12 support.
  • An API key provided by Freedom Pay.
  • The Freedom ID SDK .xcframework file provided by Freedom Pay
[!info] How to get API KEY and .xcframework file?
In order to get your API KEY and .xcframework you need to contact Freedom Pay providing the following data:
  • Bundle Identifier
  • Team ID from Apple Developer Concole
Installation Instructions
  1. Open Project Settings in Xcode
  2. Select required Target
  3. Go to General Tab and in Frameworks, Libraries, and Embedded Content and click +
  4. Select Add Other... and then Add files...
  5. Choose FreedomID.xcframework
  6. Now you can import SDK and use it further
import FreedomID
Usage
Initialize the SDK
To initialize the Freedom ID SDK, call the create method of the FreedomID class. This method requires one parameter:
  • The API key provided by Freedom ID.
let freedomID = FreedomID.create(apiKey: "your_api_key")
Authorize a User
To authorize a user, call the authorize method of the FreedomID class. This method initiates the authorization flow.
The authorize method takes three parameters:
  1. The UIViewController of your app where the authorization flow will be displayed.
  2. An array of DataGrants that the user needs to grant.
  3. A callback function that will be invoked when the authorization flow completes.
The authorization process returns an Result object, which can be either:
  • .success: Contains a GrantedProfile object.
  • .failure: Specifies the type of error that occurred.
Here’s an example:
let grants = [DataGrants.readFirstname, DataGrants.readLastname]

freedomID.authorize(viewController: self, dataGrants: grants) { (result: Result<GrantedProfile, AuthError>) in
    switch result {
    case .success(let grantedProfile):
        // Authorization successful 🚀
        let fullname = grantedProfile.firstname + " " + grantedProfile.lastname
        // Do something with the grantedProfile
    case .failure(let error):
        // Authorization failed ⛔
        // Handle the error accordingly
        break;
    }
}
Clear the SDK
To clear the SDK, call the clear method of the FreedomID class.
This method clears the SDK’s internal state and releases any resources used during the authorization process.
FreedomID.clear()
Authorization Flow
App Initialization
When the user opens the app, it automatically checks if there are any accounts tied to their device.
Account Check
  • If an account exists: The user is navigated directly to the Home Screen, where their account(s) are displayed.
  • If no account exists: The user is taken to the Authentication Screen to log in. After successful authentication, the user is redirected to the Home Screen.

Authentication Screen Interaction
The user can log in using any of these methods:
  • Entering their phone number and receiving an OTP code via SMS.
  • Entering their email and password as credentials.
  • Entering their phone number and password as credentials.
Optionally, users can enable 2FA for additional security. To enable 2FA, they need to manage their settings in their Freedom ID account on the web at https://passport.freedompay.kz

Home Screen Interaction
  • On the Home screen, users see their account(s).
  • Users select an account for which they need to request data permissions and apply fingerprint
Request for Permissions
  • After selecting an account, the app presents the Permissions Request Screen.
  • Users review the requested permissions (e.g., access to specific user data).

User Decision
  • Permissions Granted ✅: The host app is granted the requested permissions.
  • Permissions Denied ❌: The app returns to the Home Screen or informs the user that permissions are needed to proceed.

Completion
Once permissions are granted, the user is notified of successful authorization, and the SDK communicates the result back to the host app.
Data Structures


DataGrants Structure

General Description
This enum represents a set of permissions that a host application can request from the SDK to grant access to specific profile data.
Each constant corresponds to a particular piece of user information, allowing the host app to selectively request access based on its needs.
Below is a table describing the different DataGrants available in the Freedom ID SDK:
GrantedProfile Structure
General Description
The GrantedProfile data class represents a user’s profile information that is accessible after the required read permissions have been granted by the host application via the SDK.
public struct GrantedProfile: Codable {
    public var id: String = ""
    public var email: String = ""
    public var emails: [String] = [ ]
    public var nationality: String = ""
    public var phone: String = ""
    public var phones: [String] = [ ]
    public var dateOfBirth: String = ""
    public var firstname: String = ""
    public var lastname: String = ""
    public var patronymic: String? = ""
    public var gender: String = ""
    public var country: String = ""

}
Result Structure
General Description
The Result representing the result of an authentication process. It has two primary branches:
  1. .success: Indicates a successful authentication with the granted user profile as its payload.
  2. .failure: Represents various types of errors that may occur during the authentication process. Each error type is modeled either as :
a. An enum static cases
b. Or enum with associated values for cases requiring additional information.
Table1: Result
Table 2: .failure contents
TransmissionErrors Structure
General Description
The TransmissionErrors enum defines a set of possible errors that can occur during the transmission of requests in an authentication or communication process.
Each error represents a specific issue related to the request’s structure, identification, application integrity, or the process of sending and receiving requests.
Table: TransmissionErrors
NetworkError Structure
General Description
The NetworkError enum defines a set of possible errors that may occur during network operations.
Each error represents a specific issue, such as connection failures, stream interruptions, or problems with request/response handling.
Table: NetworkError
Support

If you have questions or need help integrating the SDK, feel free to reach out! 👋
Email: support@freedompay.kz