Last active
October 16, 2020 22:57
-
-
Save MarcoEidinger/c07189b18e6755c6f97ee78b2f8275fd to your computer and use it in GitHub Desktop.
How-to access managed iOS Configuration with SAP Cloud Platform SDK for iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>UserEmailAddress</key> | |
<string>currentDeviceUser@company.com</string> | |
<key>EnvironmentSetting</key> | |
<string>production</string> | |
</dict> | |
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<managedAppConfiguration> | |
<version>1</version> | |
<bundleId>com.mobileiron.demo.SAP-Demo-App-ManagedConfig</bundleId> | |
<dict> | |
<string keyName="UserEmailAddress"> | |
<defaultValue> | |
<value>${userEmailAddress}</value> | |
</defaultValue> | |
</string> | |
<string keyName="EnvironmentSetting"> | |
<defaultValue> | |
<value>production</value> | |
</defaultValue> | |
</string> | |
</dict> | |
<presentation defaultLocale="en-US"> | |
<fieldGroup> | |
<name> | |
<language value="en-US">Demo Group</language> | |
</name> | |
<field keyName="UserEmailAddress" type="input"> | |
<label> | |
<language value="en-US">User email address</language> | |
</label> | |
<description> | |
<language value="en-US">This is the email address of the logged in user</language> | |
</description> | |
</field> | |
<field keyName="EnvironmentSetting" type="select"> | |
<label> | |
<language value="en-US">Environment</language> | |
</label> | |
<description> | |
<language value="en-US">Please choose the environment setting for this demo app</language> | |
</description> | |
<options> | |
<option value="production" selected="true"> | |
<language value="en-US">Production</language> | |
</option> | |
<option value="Development"> | |
<language value="en-US">Development</language> | |
</option> | |
</options> | |
</field> | |
</fieldGroup> | |
</presentation> | |
</managedAppConfiguration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment