iOS Setup¶
Installation¶
Ansa is available via Swift Package Manager.
- Follow the instructions for adding package dependencies to your app in Xcode.
- In the "Enter Package URL" field, enter this GitHub repository:
- Select the version of the SDK for iOS that you want to use. For new projects, we recommend specifying the latest version and using the "Exact Version" option.
- Import
AnsaCore
Initialization¶
Initialization of the SDK requires your merchant publishable key from onboarding as well as setting up a ClientSecretProvider
implementation.
/// Interface to provide Ansa with a short-lived token for access customer specific endpoints.
public protocol ClientSecretProvider {
/// Provider for a short lived token for accessing customer specific endpoints.
/// * Parameters:
/// * ansaCustomerId: unique identifier for a given customer
///
/// * Returns: a short lived token for this customer
func provideClientSecret(ansaCustomerId: String) async -> String?
}
To initialize the SDK, call:
AnsaSdk.initialize(
publishableKey: "your publishable key",
clientSecretProvider: ClientSecretProviderImpl()
)
Logging¶
Ansa supports allowing you to hook up any logging internally in AnsaClient to your preferred logging framework (swift-log, SwiftyBeaver, etc.) via a logging plugin during init()
.