This guide will cover both iOS (Swift) and Android (Kotlin) integrations.
Adding On-Site Messaging to your native app is a straightforward process. At a high level, to achieve this tailored experience for your users, you will need to follow these 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 your screen.
sequenceDiagram
participant C as Customer
participant P as Partner
participant K as Klarna
participant AP as Acquiring Partner
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
alt Partner builds checkout form
K->>P: Prequalification state preserved
else Checkout form via Acquiring Partner
P->>K: Fetch klarna_network_session_token
P->>AP: Share klarna_network_session_token
end
end
The client ID of the partner account that is integrating the Mobile SDK. If the integration is done by a PSP/DP then this must be set to the distribution partners own client ID.
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 only retrievable server-side via the Network Session API.
The On-Site Messaging native view is called KlarnaMessagingPlacementView. You can create this view programmatically and add it to your layout with your 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(