Integrate On-site messaging with Klarna mobile SDK
Boost transparency and conversions by integrating Klarna’s Mobile SDK to display payment messaging and pre-qualification, letting customers check financing eligibility before they buy.
This guide covers both iOS (Swift) and Android (Kotlin) integrations.
Adding On-site messaging to a native app is a straightforward process. At a high level, achieving this tailored experience requires the following steps:
Request access to On-site messaging.
Add the Mobile SDK Messaging library.
Initialize the Klarna SDK.
Create the native messaging view and add it to the screen.
sequenceDiagram
participant C as Customer
participant P as Partner
participant K as Klarna
P->>K: Initialize Klarna SDK
P->>K: Get OSM placement
K->>P: Return messaging/prequalification content
P->>C: Display messaging/prequalification content
alt Prequalification flow - Approved
C->>K: Clicks to check purchase power
K->>C: Start prequalification journey
C->>K: Completes prequalification
K->>P: Send approval event & updated messaging
K->>C: Update placement to show approval
Note over P,K: Prequalification state preserved via Klarna Network Session Token
end
The client ID of the partner account that is integrating the Mobile SDK.
locale
String
Optional
Set the default locale(ISO 3166-1 alpha-2) for the SDK. System default locale will be used if not set.
klarnaNetworkSessionToken
String
Optional
The Klarna Network Session Token allows the SDK to be initialized with an existing session. The token is retrievable server-side via the Network Session API.
The On-site messaging native view is called KlarnaMessagingPlacementView. This view can be created programmatically and added to the layout with the desired layout options.
SWIFT
1
2
3
4
5
6
7
8
9
10
// Create an instance of KlarnaMessagingPlacementConfiguration// Depending on your requirements, you can create `CreditPromotionBadge` or // `CreditPromotionAutoSize` configurationlet placementConfiguration = KlarnaMessagingPlacementConfiguration.creditPromotionBadge(
theme: .automatic,
amount: 10000,
currency: "USD"
)
// Create an instance of the viewlet placementView = KlarnaMessagingPlacementView(