Skip to main content

Offline Login

Offline login allows an already activated user to authenticate when offline by validating stored offline tokens. If the token is valid, the MC (Master Controller) returns a status OK. If the offline token is invalid or the login fails, it is recommended to initiate an IDP login with the same authentication method used previously.

Example Flow:

  • If biometric login is enabled:
    Offline login fails → Trigger an IDP login page → Perform login using biometric authentication mode.

For repeated login failures (e.g., unrecognized fingerprints), prompt the user for an alternative authentication method.


Shift Lite - Connect Offline Login Flow

The event flow diagram illustrates the sequence of events during the Offline Login process for KOBIL Shift Lite.


Swift/iOS

The Offline Login function validates the token stored on the device. It sends the necessary request (tenantId and clientId) to trigger the anonymous enrollment event. Once the enrollment is processed, the result is handled accordingly.

Here’s an example for triggering the Offline Login flow in Swift/iOS:

public func performOfflineLogin(
userIdentifier: KsUserIdentifier,
completion:@escaping ((KSMOfflineLoginResultEvent) -> Void?)) {

let offlineLoginEvent = KSMOfflineLoginEvent(
userIdentifier: userIdentifier,
authenticationMode: KSMAuthenticationMode.no
)

self.masterControllerAdapter.sendEvent2MasterController(offlineLoginEvent) { event in
guard let macroEvent = event as? KsMacroEvent else { return }
guard let resultEvent = macroEvent as? KSMOfflineLoginResultEvent else { return }
completion(resultEvent)
}
}

Android/Kotlin

The Offline Login flow in Kotlin follows a similar structure, validating the offline token and prompting for re-authentication if necessary.

Here’s an example for triggering the Offline Login flow in Kotlin:

fun triggerOfflineLoginEvent(userIdentifier: UserIdentifier) {
val offlineLoginEvent = OfflineLoginEvent(userIdentifier)
mcEventHandler?.postEvent(offlineLoginEvent)?.then {
logDebug("Received OfflineLoginResultEvent: $it", "triggerOfflineLoginEvent")
// Handle result
}
}

Request Parameters

Below are the request parameters used in the Offline Login flow:

userId: The unique user identifier for the user attempting to log in.
tenantId: The tenant associated with the user.


Notes on Authentication Modes

In Shift Lite, you can configure various authentication modes during the Anonymous Enrollment process. For more details, refer to the section on authentication modes.

For more details on event handling, you can also refer to the AnonymousEnrollEvent and AnonymousEnrollResultEvent events.


Conclusion

With these steps, users can log in offline without needing internet connectivity. If offline tokens are invalid, the fallback IDP login ensures continuous access. The provided code examples for both iOS/Swift and Android/Kotlin offer easy integration paths for mobile apps to leverage Shift Lite Connect offline login capabilities.