Retrieve SDK Custom Settings

Many enterprise applications require users to enter URL, port, email address, and various configurations as part of a one time setup of an  application. These manual configurations can impact the adoption and success of an organization’s mobile app initiatives, increase the burden on a help desk fielding calls from users, and adds the burden of maintaining documentation that needs to be updated frequently as new updates to the application are made available.

In the previous section, we had to enter the Exchange URL manually. Now we will see how can we populate that URL automatically into our app via Custom Settings from a SDK profile pre-configured in the AirWatch EMM console.

1. Xcode implementation to retrieve SDK custom Settings

We have already configured the SDK profile for you in which the Custom Settings payload contains the internal URL of the Exchange Server. In this section, we will implement the code required to retrieve the custom settings and auto-populate the Exchange URL in the app.

1.1. Implement Received Profiles in RFAppDelegate.swift

  1. Click on "RFAppDelegate.swift".
  2. Code snippet for receivedProfiles:

  func receivedProfiles(profiles: [AnyObject]!) {

       if let allProfiles = profiles {

           for profile in allProfiles {

               if let awProfile = profile as? AWProfile {

                   if awProfile.comments == SDKProfileKeys.sdkProfileDescription.rawValue{

                       //this is sdk profile

                       if let customPayloadSettings = awProfile.customPayload?.settings {

                           let rootViewController = self.window?.rootViewController?.childViewControllers[0] as? RFLoginViewController








1.2. Add method setURL

Add method setURL
  1. Navigate to RFLoginViewController.swift
  2. Add the method as per the screenshot:

func setURL(urlString:String){

       self.serverTextField.text = urlString

       loginButton!.enabled = self.serverTextField.text?.characters.count > 0


1.3. Source Tree Checkout to Retrieve URL

Source Tree Checkout to Retrieve URL

You can also checkout the code implementation so far by checking out the commit "Retrieve URL".

2. Validate Custom Settings on the enrolled device

In this step, we are going to run the application from Xcode to validate that we can auto-populate the URL on the enrolled device.

2.1. 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 that URL is auto-populated

Validate that URL is auto-populated
  1. Validate that URL is automatically populated in the text field. This URL is extracted from the custom settings of the SDK profile pre-configured in the AirWatch Admin Console for this lab. (Note: You may see an authentication prompt to enter passcode if the authentication timeout has expired. Type in "1111" to continue.)
  2. Click on "Login" to continue.

2.3. Login Authentication Prompt

Login Authentication Prompt

Now, we have configured our application to fetch the Exchange URL automatically. In the step, we will see how we can configure our application to pass the enrollment credentials securely when we see an authentication prompt.


Add your comment

E-Mail me when someone replies to this comment

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