Authenticating Fiori Apps using Touch ID and Passcode Controller

Introduction Welcome to part 6 of the blog series on exploring the SAP Cloud Platform SDK for iOS assistant. In this blog we would add ...

Contact us

Introduction

Welcome to part 6 of the blog series on exploring the SAP Cloud Platform SDK for iOS assistant. In this blog we would add native iOS touch ID feature and Fiori Passcode Controller for iOS.

 

Business Scenario

Sales executives are always on the field using their gadgets and engaged in the lead generation process. Often, they would like to have the information about their contacts / leads and would like to know the correspondence history or action items pending on a given lead.

Entering the credentials for HCP is often time consuming and this could be minimized by using TouchID feature. The Sales executive could also enter a 4 digit Passcode to login.

Goal in this blog

To build the below application using Custom Fiori iOS Controls – Passcode controller

          

Upon activation of the touchID the user would be prompted for Touch. One could also use the passcode established to login.

          

 

Let’s play with code

The guts of the code is implemented in the AppDelegate.swift file

The custom Fiori Controller – PasscodeController has an inbuild storyboard which gets invoked upon initiatlization.

The controller provides 2 storyboard resources, each of them has their own view controller.

  1. PasscodeInputController, VC – PasscodeInputViewController
  2. PasscodeCreateController, VC – PasscodeCreateFirstViewController

 

 

Code excerpts from App delegate:

class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate, UNUserNotificationCenterDelegate,PasscodeControllerDelegate {

 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

 

self.window?.makeKeyAndVisible()

 

 

let defaults = UserDefaults.standard

if let passcode = defaults.value(forKey:passcodeKey ) as? String {

 

// Check if passcode is already available

/ let storyboardBundle = Bundle(for: PasscodeInputController.self)

let storyboard = UIStoryboard(name: “PasscodeInputController”, bundle: storyboardBundle)

vc = storyboard.instantiateViewController(withIdentifier: “PasscodeInputViewController”)

let passcodeVC = vc as! PasscodeInputController

passcodeVC.delegate = self;

// present the passcode view

let navController = UINavigationController(rootViewController: passcodeVC)

 

self.window?.rootViewController?.present(navController, animated: true, completion: nil)

}

else{

 

 

let storyboardBundle = Bundle(for: PasscodeCreateController.self)

let storyboard = UIStoryboard(name: “PasscodeCreateController”, bundle: storyboardBundle)

vc = storyboard.instantiateViewController(withIdentifier: “PasscodeCreateFirstViewController”)

let passcodeVC = vc as! PasscodeCreateController

passcodeVC.isSkipPasscodeAllowed = true

passcodeVC.delegate = self;

// present the passcode view

let navController = UINavigationController(rootViewController: passcodeVC)

 

self.window?.rootViewController?.present(navController, animated: true, completion: nil)

}

Now that you’re done, your finished product will look like this:

 


AUTHOR

Naveen Rokkam, currently leads the Innovation Practice at Mindset. He is responsible for Product Development, research and Innovation at Mindset. He is a technology evangelist and SAP Practioner with more than a decade experience in developing and implementing new Software Products using SAP. He was part of the Technology Innovation Platform group in SAP Labs and contributed toward the development of Netweaver 8.0, Process Integration and Business ByDesign. His research interests span across Internet-of-Things, Machine Learning, Big Data and Mobile App development.

SOURCE CODE

Get started on your SAP Cloud Platform SDK for iOS experience. Click here to request the full project code

Naveen Rokkam

Naveen Rokkam

Naveen Rokkam is a technology leader with a strong passion for strategy and management. In his role as Vice President of Strategic Accounts, he leads large scale digital transformation projects. He is passionate about exploring new ways to create remarkable solutions by leveraging the latest technologies. He is a regular speaker at SAP events including SAP TechED, SAPPHIRE, and ASUG events.

Let’s make your SAP better, together.

  • This field is for validation purposes and should be left unchanged.