Skip to main content

Seamless Login

Seamless Login​

Overview​

The CoreAdapter SDK allows partner applications to implement seamless login for their users. This document outlines the steps and methods required for setting up and handling seamless login, both with and without the SDK loader UI.

Setup​

Import the CoreAdapter​

import CoreAdapter

Application Configuration​

In your AppDelegate, configure the CoreAdapter for seamless login:

AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
CoreAdapterConfig.seamlessLoginSetup(with: self)
}

Seamless Login with SDK Loader UI​

Implement the SeamlessProtocol​

Extend the AppDelegate to conform to the SeamlessProtocol and handle the seamless login flow:

 // seamless login using sdk loader UI
extension AppDelegate: SeamlessProtocol {

func onNucleiSeamlessLoginRequest() {
// Here partner application will get the temporary token from their server.
// Once it receives the token, send the token to SDK by calling following method
let token = <"Token">
CoreAdapterSetup.validateSeamlessToken(token, mobileNumber: <"Mobile number">, countryCode: <"country code">)
}

func seamlessLoginDidSucceed() {
print("Seamless login succeeded")
// partner will receive a call back after login is successful
// partner will be having access to our module here after

}

func seamlessLoginDidFail(_ error: NSError) {
// partner will receive a call back after login is not successful
print("Seamless login failed")
print(error)
}
}

Silent Login without SDK Loader UI​

ViewController Setup​

In your ViewController, configure the CoreAdapter for seamless login:

// Silent login without sdk loader UI
class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

CoreAdapterConfig.seamlessLoginSetup(with: self)

if CoreAdapterSetup.isNucleiSignedIn() == false {
// Call generate token method
// Once it receives the token, send the token to SDK by calling following method
let token = <"Token">
CoreAdapterSetup.validateSeamlessToken(token, mobileNumber: <"Mobile number">, countryCode: <"country code">)

}
}
}

Implement the SeamlessProtocol​

Extend the ViewController to conform to the SeamlessProtocol:

extension ViewController: SeamlessProtocol {

func onNucleiSeamlessLoginRequest() {
// Call generate token method and validate received token
let token = <"Token">
CoreAdapterSetup.validateSeamlessToken(token, mobileNumber: <"Mobile number">, countryCode: <"country code">)
}

func seamlessLoginDidSucceed() {
print("Seamless login succeeded")
// partner will receive a call back after login is successful
// partner will be having access to our module here after

}

func seamlessLoginDidFail(_ error: NSError) {
// partner will receive a call back after login is not successful
print("Seamless login failed")
print(error)

}
}

Methods​

seamlessLoginDidSucceed()​

This method is called by the Nuclei SDK once the user is successfully logged in using the seamless flow.

seamlessLoginDidFail(_ error: NSError)​

This method is called by the Nuclei SDK if the seamless login fails.

onNucleiSeamlessLoginRequest()​

This method is called by the Nuclei SDK when a Nuclei service is invoked and the user is not logged in. The partner application can process the seamless login for the user.

Additional Notes​

Check if User is Logged In​

The partner application can check whether the user is logged in or not using the following method:

let isSignedIn = CoreAdapterSetup.isNucleiSignedIn()

If the user is not signed in, you can initiate the seamless login flow as described above.