ClientConfiguration
public struct ClientConfiguration
Configuration for your client. Allows client to set their ID and decide which backend environment to point the SDK at.
This is the first structure you must create in your SDK. Typically, an application will have one for testing/debugging purposes and one that is used in a production environment. A tip for organizing them would be to have it globally available in your applications:
extension ClientConfiguration {
static let debug = ClientConfiguration(
...
)
static let production = ClientConfiguration(
...
)
}
API calls will NOT work accross different ClientConfiguration objects. If you have state that is left over after using one ClientConfiguration, and then you try and use that state with a different ClientConfiguration, you will not get the results you want.
This object is used to set your ClientConfiguration.Environment
, your
ClientConfiguration.appURLScheme
and your locale.
App URL Scheme
If you want deep linking to work, then you must specify your app’s URL scheme as well. For Schibsted account mobile clients, the scheme is fixed and is available from the Schibsted account Self Service.
You should specify this string value when creating your ClientConfiguration and you should also register the url scheme as per Apple guidelines.
See also
Schibsted account Self ServiceSee also
Apple docs: Inter App Communication-
Determines which backend requests will be sent to. Most of the values here are explained in Schibsted account Self Service where you also must set up your client.
Basically this is what determines if this is a production configuration, or pre production, etc. Please read the Schibsted account Self Service
See also
Schibsted account Self ServiceDeclaration
Swift
public enum Environment : String
-
All SDK requests will be served to this URL.
Is is either determined by an
Environment
that you specify or can also be a custom URL, which may be handy for local testing.Declaration
Swift
public let serverURL: URL
-
The client id that this object was initialized with
Declaration
Swift
public let clientID: String
-
The locale that is being used
Declaration
Swift
public let locale: Locale
-
Which environment (if any) is this configuration using
Declaration
Swift
public let environment: Environment?
-
Alternative initializer if you do not want to specify a pre-existing
Environment
. Usually used for testing.Declaration
Swift
public init(serverURL: URL, clientID: String, clientSecret: String, appURLScheme: String?, locale: Locale? = nil)
Parameters
serverURL
the backend server URL to talk to.
providerComponent
the backend server provider URN.
clientID
unique client identifier for this client.
clientSecret
the secret associated with the client ID
appURLScheme
set your
appURLSceheme
here. Defaults tospid-\(clientID)
if nillocale
Locale you want to use for requests - defaults to system
-
Initialize a new configuration for a specific
Environment
Declaration
Swift
public init(environment: Environment, clientID: String, clientSecret: String, appURLScheme: String?, locale: Locale? = nil)
Parameters
environment
the backend environment to talk to. Can be one of the pre-defined environments.
clientID
unique client identifier for this client.
clientSecret
the secret associated with the client ID
appURLScheme
set your
appURLSceheme
. Defaults tospid-\(clientID)
if nillocale
Locale you want IdentityManager to use for requests
-
This is used for generating the redirect URI needed for going back to the app. You can find this in the Schibsted account Self Service under the
Redirect
tab for your client. It must be equal to the value underCustom URI Scheme
You will also have to register the scheme in the your apps Info.plist
URL Types
underURL Schemes
.See also
Apple docs: Inter App CommunicationDeclaration
Swift
public let appURLScheme: String
-
Base URL for redirects that will be created by the SDK for various API calls.
The way this is constructed depends on your
appURLScheme
. The SDK currently supports two formats that Schibsted account uses:- format0 - this is in the format of
spid-
- SDK treats this as default. - format1 - this is in the format of
.
Schibsted account has a number of default routes set up for mobile clients (referred to as roots in the SDK - see
redirectURLRoot
). The way these are added to a redirect depends on the format of your app scheme.With format0 Schibsted account adds the root s a URL host component. I.e. scheme://root. This is usually
login
and the SDK defaults to that, but it can be others (see your self service and they will be listed there). For format1, the root is a URL path component. I.e. scheme://host/path-component. And the host (or more accuratelyauthority
) URL component is omitted, which means the format is: scheme:/rootSee also
SeeAlso
redirectURLRoot
Declaration
Swift
public func redirectBaseURL(withPathComponent path: String?, additionalQueryItems: [URLQueryItem]? = nil) -> URL
Parameters
withPathComponent
if specified, a
path
url query item will be added to the URL with the value of this argumentadditionalQueryItems
if you want any additional query items added to the URL
- format0 - this is in the format of
-
The result of parsing a redirect URL deep link
Declaration
Swift
public typealias RedirectPayload = (path: String?, queryComponents: [String : [String]])
-
Returns a
RedirectPayload
that contains data that can be used byAppLaunchData
to extract deep link related informationThe redirectURL must have been generated via
redirectBaseURL
and contain theappURLScheme
inside for it to be valid.Declaration
Swift
public func parseRedirectURL(_ redirectURL: URL) -> RedirectPayload?
Return Value
A tuple of path and queryComponents if the URL was a valid redirectURL
-
Declaration
Swift
public static func == (lhs: ClientConfiguration, rhs: ClientConfiguration) -> Bool
-
Declaration
Swift
public var description: String { get }