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.
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.
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.
We’re building the SDK with Module Stability and ensuring that it will work with any Xcode 11+ version and Swift compilers.
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 particular toolchain.
For more information, check out the Klarna Mobile SDK Github repository.
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.
The SDK requires camera access to be used in Card Scan when available. Please add NSCameraUsageDescription with a description to your Info.plist.
To use the Klarna app to improve user experience during the authorization process, you must add Klarna’s app scheme (klarna, klarnaconsent) to your application Info.plist file as an entry in the list LSApplicationQueriesSchemes.
Once the values above are added, It will allow the SDK integration to properly identify if the Klarna app is installed and then perform an app switch for authorization and then return to your application with the response.
Both the Klarna Payments native integration and the hybrid integration are available under the KlarnaMobileSDK module.
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:
You can read the device identifier with the static function
deviceIdentifier() on your
This device identifier is stored in user defaults.
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 the setLoggingLevel() static function on KlarnaMobileSDKCommon
|KlarnaLoggingLevel||The type of events or level the SDK should log at.|
|Nothing will be logged into console.|
|Only errors will be logged into console.|
|Everything will be logged into console.|