Skip to Content
Technical Articles

App Configuration Using a Managed Configuration Provider

Motivation

Do you develop native iOS applications with the SAP Cloud Platform SDK for iOS and do you want to allow app configuration with your preferred UEM/MDM provider?

If you are pretty new to this topic then I recommend this introductory blog post by MobileIron. It describes how to create and upload app configuration based on the AppConfig XML specification. This has quite some advantages but also one major drawback: you cannot define nested /hierarchical app configuration. To achieve this UEM/MDM providers also allow uploading a “Property list” (.plist) representing the app configuration.

In this article, I will help you to understand how to read the configured values inside the application. Hence, it doesn’t matter how the configuration was created. In the end, the UEM/MDM provider will push the configuration to the device and it will be stored in the UserDefaults under a specific key. This is also known as iOS Managed App Configuration.

How-To handle …

Feature Configuration

The SDK’s Foundation framework provides a ManagedConfigurationProvider API which provides out-of-the-box support to read iOS Managed App Configuration pushed to a device.

Connectivity Configuration

The app needs to know which SAP Cloud Platform mobile service instance it has to connect and which authentication strategy to be used. The Assistant will generate a property list (ConfigurationProvider.plist) containing that information and the app includes this property list as part of its binary.

In this example, we will apply host information from the managed app configuration and override the generated ConfigurationProvider.plist

 

Appendix

  • SDK’s official documentation
  • Mobilerion: Deploy a configuration to your native iOS SAP Fiori app using MobileIron UEM
  • Feature Configuration Example (copy-to-clipboard capable)
    import SAPFoundation
    
    // assuming a MDM/UEM provider pushed the following managed iOS configuration to device
    // <plist version="1.0"><dict><key>UserEmailAddress</key><string>currentDeviceUser@company.com</string></dict></plist>
    // get managed iOS configuration as dictionary
    let managedConfigDic = ManagedConfigurationProvider().provideConfiguration().configuration
    
    // access entry of managed iOS configuration
    print("Value \(managedConfigDic["UserEmailAddress"]) equals 'currentDeviceUser@company.com' according to plist pushed by MDM/UEM provider")​
  • Connectivity Configuration Example (copy-to-clipboard capable)
    import SAPFoundation
    import SAPCommon
    import SAPFiori
    import SAPFioriFlows
    
    // assuming SAP Cloud Platform SDK for iOS Assistant was used to generate onboarding
    // then ConfigurationProvider.plist with connectivity settings (e.g. host) was created as well
    // assuming a MDM/UEM provider pushed the following managed iOS configuration to device
    // <plist version="1.0"><dict><key>host</key><string>cfSpaceMobileApp.cfapps.sap.hana.ondemand.com</string></dict></plist>
    // goal: override host information in in ConfigurationProvider.plist with value from managed iOS configuration
    // Where to apply the following code: OnboardingFlowProvider.swift (generated by Assistant)
    // step 1: create a custom transfomer to take information from managed iOS configuration and
    // override standard discoveryServiceConfig as specified in ConfigurationProvider.plist
    class CustomDiscoveryConfigurationTransformer: ConfigurationTransforming {
        func transform(config: Any) throws -> [OnboardingInfoKey: Any] {
    
            guard var discoveryServiceConfig = config as? [String: Any] else {
                return [:]
            }
    
            discoveryServiceConfig["host"] = ManagedConfigurationProvider()
                .provideConfiguration()
                .configuration["host"]
            discoveryServiceConfig["port"] = 443
    
            let settingsParameters = try SAPcpmsSettingsParameters(
                applicationID: "your-applicationID-as-specified-in-CPms",
                discoveryServiceConfig: discoveryServiceConfig
            )
    
            return [OnboardingInfoKey.sapcpmsSettingsParameters: settingsParameters]
        }
    }
    
    // step2: use transfomer in standard DiscoveryServiceConfigurationTransformer
    let discoveryConfigurationTransformer = DiscoveryServiceConfigurationTransformer(
        applicationID: "your-applicationID-in-CPms",
        authenticationPath: "your-authenticationPath-as-specified-in-CPms",
        customConfigurationTransformer: CustomDiscoveryConfigurationTransformer()
    )​
Be the first to leave a comment
You must be Logged on to comment or reply to a post.