Manage other iOS SDK operations
The following describes how to work with miscellanous iOS SDK payment operations like presenting settings, aborting operations, and logging users out programatically.
About SDK operations
Important notice when calling the methods described here:
- In Objective C, only use the singleton instance returned from
[iZettleSDK shared]
. - In Swift, only use the singleton instance returned from
iZettleSDK.shared()
.
The iOS SDK will handle presentation and dismissal of its views. Operations with UI will accept a UIViewController
as an argument. From this the Zettle SDK will be presented. A login screen is displayed if the user has not yet been authenticated with Zettle.
Asynchronous operations have a completion block as an argument. This completion block is called when an operation is considered complete, cancelled or failed. See completion handling in Manage card payments and Manage PayPal QRC payments.
Presenting settings
This example shows how to make the Zettle Settings view appear to users. From this, users can switch account, access the FAQ, and see card reader settings.
Objective C
1- (void)presentSettingsFromViewController:(UIViewController *)viewController;
Swift
1open func presentSettings(from viewController: UIViewController)
Aborting operations
This example describes how to abort an ongoing operation if needed.
Note: Aborting an ongoing operation should only be attempted if absolutely necessary. This is because the state of the payment will be unknown to the user after this call.
Objective C
1- (void)abortOperation;
Swift
1open func abortOperation()
Enforced user account
This example shows how to restrict the usage of the SDK to a specific Zettle account. The account to be used is defined in the iZettleSDKAuthorization
object during the SDK initialization. See Installation and configuration.
Swift
1var enforcedAccount = { "name@zettle.com" }23let authenticationProvider = try iZettleSDKAuthorization(4clientID: "xxx-xxx-xxx-xxx",5callbackURL: URL(string: "app-scheme://url")!,6enforcedAccount: enforcedAccount)78iZettleSDK.shared().start(with: authenticationProvider)
The enforced account will be evaluated for each authenticated operation performed in the SDK.
Logging out programmatically
This example shows how to log out a current account.
Objective C
1- (void)logout;
Swift
1open func logout()
Errors
Zettle will display any errors that occur during an operation to the end user. The NSError-object returned in the operation completion block is only intended for developers. The object provides more detailed information useful for debugging, diagnostics and logging. You should never present errors returned in this format to the end user.