To ensure the Sign in flow initiated by the SDK can correctly redirect back to your application, you must configure a unique return URL (deep link) for your app and provide this URL string to the SDK. This value is required specifically for the Sign in flow initiated by the SDK.
Important: This configuration is distinct from any other return URLs the SDK might require for handling redirects from external third-party applications. Ensure you are configuring the URL for the SDK's Sign in flow.
Add this snippet to your manifest file in order to set your return URL value for the SDK’s activity.
Before starting to work with the Sign In With Klarna, the Android and iOS parts of your React Native app need to be updated in order to provide the best experience and functionality to the users. Please read and follow the before you start -> setting the return url guide for Android and preparation guide for iOS.
If an instance of KlarnaSignInSDK is initialized correctly, you will get a reference to it in the promise return value. If there is an error during initialization, it will be returned in the catch block of the promise.
An enumeration that is used to configure the endpoints and other behaviours that the KlarnaSignIn will be operating with. The possible values are as follows. If not set, the default value will be production.
playground
production
staging
region
String
No
An enumeration that defines the regional API endpoints to which the KlarnaSignIn flow will send/receive requests. The possible values are as follows. If not set, the default value will be eu.
eu
na
oc
returnUrl
String
Yes
The URL you defined as your redirect URI for Sign in with Klarna integration in the preparation section. You can find more information about the URL in our iOS getting started guide and Android before you start guide.
After calling the signIn function, the sign in flow will be presented to the user. When the user finishes the sign in flow, you would either receive a successful or an error result in the promise returned by the signIn function.
There are two main action values to look for, KlarnaSignInUserCancelled triggered when the user cancelled the flow at any point and the KlarnaSignInToken event, received after the signIn process is completed. You can get the tokens from the KlarnaProductEvent params for KlarnaSignInToken event and send it to your backend.
When the signIn method resolves, a KlarnaProductEvent is returned as a result.
This event type includes three properties, action, params and sessionId.
NAME
TYPE
DESCRIPTION
action
String
Represents the name of the event.
params
String
Contains a payload that may or may not be returned, depending on the specific event.
sessionId
String
An identifier that can be useful when contacting Klarna for support.
After the flow is complete and the token has been retrieved and you no longer need the KlarnaSignInSDK instance, you can call the dispose() method to release the resources used by the object.