Adding the SDK via Cocoapods
If you’re using Cocoapods, you can add the SDK by adding the dependency to your Podfile:
Followed by performing:
You should then be able to import the
KlarnaMobileSDK module in your workaspace.
Adding the SDK via Carthage
If you’re using Carthage, you can add the SDK to your Cartfile as below:
Followed by performing:
You should be then able to add the
.framework to your project.
Adding the SDK via Swift Package Manager (SPM)
In Xcode, navigate to File → Swift Packages → Add Package Dependency and enter the repository URL:
In Version, Select Up to Next Major and take the default option. Then choose
KlarnaMobileSDK in the Package Product column.
The SDK also supports multiple versions of Xcode and Swift if needed. All of these are the same SDK version, but generated with different toolchains. You can see the default version in the podspec. However, if you want to use a specific Xcode build, we offer subspecs (that you can see in the project’s podspec) for your specific toolchain.
Both the hybrid and native integrations might, at some point, open third-party applications. To automatically return the user, these third-party applications need to know about your app’s shema.
To do that, you’ll need to provide the SDK with what we call a “return URL” parameter. If you haven’t done so already, you can add the schema to your app’s plist.
Importing the SDK
Both the Klarna Payments native integration and the hybrid integration are available under the
A Common Class For Cross-cutting Concerns
Some features in the SDK are relevant for both native and hybrid integrations of the SDK. These
are accessible under the
CommonMobileSDKCommon class. These features are:
- Setting a logging level.
- Reading the device identifier.
1. Reading the Device Indentifier
You can read the device identifier with the static function
This device identifier is stored in user defaults.
Read the Identifier
2. Setting the Logging Level
The SDK will log events and errors to the system’s log while it’s running. You can read these through
XCode’s console or the Console app in Mac OS. You can set the logging level for the SDK through
setLoggingLevel() static function on
DescriptionThe type of events or level the SDK should log at.
DescriptionNothing will be logged into console.
DescriptionOnly errors will be logged into console.
DescriptionEverything will be logged into console.
[KlarnaMobileSDKCommon setLoggingLevel: KlarnaLoggingLevelVerbose];