User

public class User : UserProtocol

The user object is the central part of the SDK. Once one is created, it is recommended to hold on to it until you do not need it anymore.

There are 2 ways to create a valid user object currently:

  1. Through the IdentityManager
  2. Through the IdentityUI

It is recommended that you create one using the provided UI flows. But if the need arises the headless approach is also documented, but not officially supported.

Checking if you have an already logged in user

The process to check that is currently supported by the IdentityManager.currentUser object. Once an identity manager is initialized, it’s internal user object is either in a logged in state or not.

Based on the state of IdentityManager.currentUser, you may either proceed to get one or store it and use it for whatever else.

In order to comply with privacy regulations, you need to make sure that the user accepts any update to terms and conditions that may have been issued since the last visit. For this reason, at the startup of your app, right after having obtained the IdentityManager.currentUser and verified the login status, if the user is logged-in you should call user.agreements.status(:) and, in case of false result (meaning the user has yet to accepted the latest terms), obtain the latest terms by calling IdentityManager.fetchTerms(:) and finally present a screen where the user can review and accept the updated terms. The recommended way of presenting the screen is by using the provided UI flows, thus by callingIdentityUI.presentTerms(for:from:)`.

If you are using the headless approach instead, you should then present your own UI and manually call user.agreements.accept(:), if the user accepted the new terms, or logout(), if the user rejected them.

  • Provides auth-related APIs

    Declaration

    Swift

    public internal(set) var auth: UserAuthAPI
  • Provides access to this user’s profile data

    Declaration

    Swift

    public internal(set) var profile: UserProfileAPI
  • Provides access to the state of this user’s terms acceptance

    Declaration

    Swift

    public internal(set) var agreements: UserAgreementsAPI
  • Provides access to product information for this user Note: This is a privileged API and access must be requested through schibstedaccount@schibsted.com for your specific client.

    Declaration

    Swift

    public internal(set) var product: UserProductAPI
  • Provides access to asset information for this user

    Declaration

    Swift

    public internal(set) var assets: UserAssetsAPI
  • Declaration

    Swift

    public weak var delegate: UserDelegate?
  • A user_id used by some Schibsted account APIs

    It is recommended to use id instead of this.

    Declaration

    Swift

    public var legacyID: String? { get }
  • id

    Returns the user id for your client, if valid

    Declaration

    Swift

    public var id: String? { get }
  • Returns current state of User object

    Declaration

    Swift

    public var state: UserState { get }
  • Initialized a user object

    Even though you can initialize a user object with a client configuration, unless you are communicating with your own test servers where authentication is bypassed, none of the APIs will really work. This user must be created via the IdentityUI or the IdentityManager to be complete.

    Else one is just another lost soul in the endless sea of digital bits.

    Declaration

    Swift

    public init(clientConfiguration: ClientConfiguration)
  • Logs a user out. Ie: Makes it invalid

    If the user is already logged out nothing will happen. If not then the delegate will be informed of a state change.

    Declaration

    Swift

    public func logout()
  • Agreement related APIs that give you information about the status of this user’s agreements acceptance.

    Agreements consists of terms and conditions and privacy policies. Acccepting agreements means the user has accepted all the agreements fetchable via IdentityManager.fetchAgreements(...)

    See more

    Declaration

    Swift

    public class Agreements : UserAgreementsAPI
  • Contains APIs that allow you get access to tokens and control some oauth related settings for a user

    See more

    Declaration

    Swift

    public class Auth : UserAuthAPI
  • Gives you access to user device related information

    See more

    Declaration

    Swift

    public class Device : UserDeviceAPI
  • Declaration

    Swift

    public var description: String { get }
  • Compare User objects by id.

    Declaration

    Swift

    public static func == (lhs: User, rhs: User) -> Bool