Offline Mode Flow for iOS
casan221saas
During a transaction, the user opts for the Offline Mode flow if her mobile does not have network coverage. This flow enables the user to use the app to generate an OTP (in offline mode) and submit the OTP for authentication.
This section covers the following topics:
For information about the APIs mentioned in these topics, see API Reference for iOS.
Steps in the Offline Mode Flow
The following steps take place when the user uses for the Offline Mode flow:
- The user opens the app.
- The user left-swipes the account that she wants to use for the transaction.
- The app displays the Generate OTP and Delete options.

- The user taps the Generate OTP option.
- The app displays the authentication types that are enabled.

- The user selects an authentication type. For example, the user selects the fingerprint authentication option.
- If transaction data signing is enabled, then the app prompts the user to use this option.

- The app can, for example, display a QR code scanner widget to enable the user to submit transaction data.
- The app displays the fingerprint authentication prompt.

- The user completes fingerprint authentication.
- After successful fingerprint authentication, the app displays an OTP. The user notes down this OTP and submits it in the application that is prompting for authentication.

Offline Mode Flow Diagram
The following flow diagram shows the sequence of API calls that take place when the user uses the Offline Mode flow.
iOS - Offline Mode Authentication

Sample Code for the Offline Mode Flow
The following is sample code for the Offline Mode flow:
// Based on the user’s selection of the authentication type, generate the offline OTP as follows. AccountDetails *accountDetailsObj = [accountDetails objectAtIndex:indexPath.row]; AuthenticationHandler * authenticationHandler = [[AuthenticationHandler alloc] init]; NSMutableArray * enabledAuthTypes = [authenticationHandler getEnabledAuthenticationTypes]; // Based on the enabledAuthTypes, prompt the user to select the authentication type. // Based on the user's selection, call the corresponding API as follows.if(authType == (AuthenticationType)USER_PIN_AUTH) { // Prompt the User to authenticate by providing the PIN OTPResponse * otpResponse = [authenticationHandler generateOTP:accountDetailsObj userPin:uPin]; // If transaction data signing is enabled, then replace the preceding API call with the following one. propertyDict is a dictionary that has the OTP_SIGNING_KEY key. // The value of this key must be the transaction data. // The OTP_SIGNING_KEY is defined in the "Header.h" header file, which should be included so that this key can be used. // OTPResponse * otpResponse = [authenticationHandler generateOTP:accountDetailsObj userPin:uPin PropertyDict:propDict]; // Based on the response, either show the OTP or an error message. } else { // else on choosing BIOMETRIC_AUTH for generating OTP and if transaction data signing is NOT enabled OTPResponse * otpResponse = [authHandler generateOTP:selectedAcctDetails SuccessHandler:^(OTPResponse * otpResponse) { if([[otpResponse status] isEqualToString:SUCCESS]) { //App displays the OTP } else { //App displays the error } } FailureHandler:^(OTPResponse * otpResponse) { //Biometric auth failed, either prompt for PIN or take further action } FallbackHandler:^(void) { // User selected for fallback to PIN authentication // Prompt the user for PIN, and call the corresponding API } CancelHandler:^(void) { // User Canceled the biometric authentication, take the further action as appropriate }]; // else on choosing BIOMETRIC_AUTH for generating OTP and if transaction data signing is enabled. // Note that propertyDict is a dictionary that has the OTP_SIGNING_KEY key. The value of this key must be the transaction data. // The OTP_SIGNING_KEY is defined in the "Header.h" header file, which should be included so that this key can be used. OTPResponse * otpResponse = [authHandler generateOTP:selectedAcctDetails PropertyDict:propDict SuccessHandler:^(OTPResponse * otpResponse) { if([[otpResponse status] isEqualToString:SUCCESS]) { //App displays the OTP } else { //App displays the error } } FailureHandler:^(OTPResponse * otpResponse) { //Biometric auth failed, either prompt for PIN or take further action } FallbackHandler:^(void) { // User selected for fallback to PIN authentication // Prompt the user for PIN, and call the corresponding API } CancelHandler:^(void) { // User Canceled the biometric authentication, take the further action as appropriate }]; }