Integrate with AirWatch SDK to setup App Passcode

An organization requires granular security and data loss protection within enterprise applications to prevent sensitive data and documents from leaking outside company control. Rather than relying solely on device passcode, it is beneficial to setup an application level authentication.

1. Xcode implementation to setup App Passcode

In this section, we are going to add some code into the Room Finder application to leverage a pre-configured AirWatch SDK Profile. We should see a prompt to setup an authentication passcode when we launch the app very first time.

1.1. Add AWSDK Header

Add AWSDK Header
  1. From the side pane, expand "RoomFinder".
  2. Select the file "RFAppDelegate.swift".
  3. Import the header "AWSDK" to start using AWSDK functions.

Note: In this section, we are going to implement all the coding into RFAppDelegate.swift file.

1.2. Implement AWController to initialize SDK

Implement AWController to initialize SDK

The AWController class is the main component responsible for initializing the SDK. In addition, it automatically handles and implements certain core SDK functionalities to improve ease of integration for developers, such as the following functions:

  • Passcode mode
  • Single sign-on(SSO)
  • SSID filtering
  • Proxy and tunneling

Complete the code as per the screenshot.

  1. Associate AWSDKDelegate to your app delegate.
  2. Initialize and  start the AWController client instance in didFinishLaunchWithOptions method.
  3. We are also defining the callback scheme so that app can get called back from the broker/ anchor app i.e. AirWatch Agent. Note: This callback scheme should be same as the one we registered with the Room Finder app in the previous step.

Calling start in AWController automatically sets up the proxy to redirect traffic. However, we must wait until the initial CheckDoneWithError callback is received before any network traffic redirects. Hence, we will make networking calls through AirWatch Tunnel proxy only after we have SDK setup is finished.

Code snippet as shown in the screenshot:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

       // Initialize SDK

       let awc = AWController.clientInstance()

       awc.delegate = self

       awc.callbackScheme = "roomfinder"

       awc.start()

       return true

   }

1.3. Handle the callback from AW Agent

Handle the callback from AW Agent

Implement the "handleOpenURL" function call as per the screenshot. This will handle the callback from the broker/ anchor app i.e. AirWatch Agent.

Code snippet as shown in the screenshot:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

       return AWController.clientInstance().handleOpenURL(url, fromApplication: sourceApplication)

   }

1.4. Implement AWSDK Delegate Callbacks

Implement AWSDK Delegate Callbacks

In this section, we will implement the AWSDK delegate callbacks to complete our class implementation. Implement the methods into the same file (RFAppDelegate.swift) as shown in the screenshot

  1. initialCheckDoneWithError is always called after SDK is initialized. Error object nil indicates initialization is succssful.
  2. wipe is invoked when device has been wiped or un-enrolled from AirWatch.
  3. receivedProfiles is called when the SDK profile assigned to the application is changed in AirWatch admin console.
  4. unlock is called when SSO session is initiated by entering correct passcode/ password.
  5. lock is called when SSO session is expired allowing developer to create a custom application block screen.
  6. stopNetworkActivity is invoked when the device connects to an SSID that is blacklisted in the SDK profile.
  7. resumeNetworkActivity is invoked when the device connections to a valid SSID after network activity is already stopped.

Code snippet as shown in the screenshot:

  func initialCheckDoneWithError(error: NSError!) {

   }

   func receivedProfiles(profiles: [AnyObject]!) {

       print("did receieve profiles called")

   }

   func wipe() {

       print("AWSDK wipe callback called!")

   }

   func lock() {

       print("AWSDK Lock callback called!")

   }

   func unlock() {

       print("AWSDK UnLock callback called!")

   }

   func stopNetworkActivity(networkActivityStatus: AWNetworkActivityStatus) {

   }

  func resumeNetworkActivity() {

   }

1.5. Source Tree Checkout for SDK Set Up

Source Tree Checkout for SDK Set Up

The code implementation so far can be checked out from Source Tree using the commit "SDK Set up".

2. Validate app level passcode on the enrolled device

In this section, we are going to validate the code implementation we performed in the previous step and confirm that we see a prompt to setup an authentication passcode on the initial launch. The complexity of this passcode is configured in a SDK profile in AirWatch Console.

2.1. Run the application via Xcode

Run the application via Xcode
  1. Ensure that you are getting Build as "Succeeded" after building your Xcode project.
  2. Select the physical device connected to your Mac.
  3. Click on "Build and then Run" icon to install the application on your enrolled iPad.

2.2. Validate the passcode setup prompt

Validate the passcode setup prompt
  1. Create new passcode as "1111".
  2. Confirm new passcode as "1111".
  3. Click on "Create" to continue.

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.