
<?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>auth</key>
<array>
<dict>
<key>config</key>
<dict/>
<key>type</key>
<string>basic.default</string>
</dict>
</array>
<key>host</key>
<string>hcpms-XXXXXXtrial.hanatrial.ondemand.com</string>
<key>protocol</key>
<string>https</string>
<key>appId</key>
<string>com.iossdk.gs</string>
<key>authPath</key>
<string>com.sap.edm.sampleservice.v2</string>
</dict>
</plist>
import SAPFioriFlows
let presentationDelegate = ModalUIViewControllerPresenter()
var myContext: OnboardingContext!
var appId: String = ""
var authPath: String = ""
var serviceURL: URL = URL.init(string: "http://empty.org")!
//Steps executed during Onboarding
private var onboardingSteps: [OnboardingStep] {
return [
self.configuredWelcomeScreenStep(),
SAPcpmsSessionConfigurationStep(),
BasicAuthenticationStep(),
SAPcpmsSettingsDownloadStep(),
SAPcpmsLogSettingsApplyStep(),
self.configuredStoreManagerStep(),
]
}
//Steps executed during Restoring
private var restoringSteps: [OnboardingStep] {
return [
self.configuredStoreManagerStep(),
self.configuredWelcomeScreenStep(),
SAPcpmsSessionConfigurationStep(),
BasicAuthenticationStep(),
SAPcpmsSettingsDownloadStep(),
SAPcpmsLogSettingsApplyStep(),
]
}
func configuredWelcomeScreenStep() -> WelcomeScreenStep {
let discoveryConfigurationTransformer = DiscoveryServiceConfigurationTransformer(applicationID: appId, authenticationPath: authPath)
//use the values from ConfigurationProvider.plist
let welcomeScreenStep = WelcomeScreenStep(transformer: discoveryConfigurationTransformer, providers: [FileConfigurationProvider()])
welcomeScreenStep.welcomeScreenCustomizationHandler = { welcomeScreen in
welcomeScreen.isDemoModeAvailable = false
welcomeScreen.headlineLabel.text = "Getting Started with the SAP Cloud Platform SDK for iOS"
welcomeScreen.detailLabel.text = "Use this app to explore the SAP Cloud Platform SDK for iOS"
welcomeScreen.primaryActionButton.titleLabel?.text = "Start"
}
return welcomeScreenStep
}
func configuredStoreManagerStep() -> StoreManagerStep {
let step = StoreManagerStep()
//If passcode policy is disabled on the server and the next line is uncommented, the app won’t be protected with a passcode
//step.defaultPasscodePolicy = nil
return step
}
func onboardOrRestore() {
myContext = OnboardingContext(presentationDelegate: presentationDelegate)
//If we previously onboarded
if let savedUUIDString = UserDefaults.standard.string(forKey: "userOnboardingID"), let uuid = UUID(uuidString: savedUUIDString) {
myContext.onboardingID = uuid
OnboardingFlowController.restore(on: restoringSteps, context: myContext) { result in
print("and the result is ...")
switch result {
case let .success(context):
print("Successfully restored")
self.myContext = context
//get host port from registration rather than hardcoded in plist with Discovery Service
//does not work when offline
//self.serviceURL = context.authenticationURL!
case let .failed(error):
print("Failed to restore: \(error)")
if (error.localizedDescription == "Passcode reset!") {
self.unregister()
}
}
}
}
//First time the app is opened so perform the onboarding flow
else {
OnboardingFlowController.onboard(on: onboardingSteps, context: myContext) { result in
print("and the result is ...")
switch result {
case let .success(context):
self.myContext = context
//get host port from registration rather than hardcoded in plist with Discovery Service
//does not work when offline
//self.serviceURL = context.authenticationURL!
UserDefaults.standard.set(context.onboardingID.uuidString, forKey:"userOnboardingID")
print("Successfully onboarded")
case let .failed(error):
print("Failed to onboard, retrying due to: \(error)")
URLCache.shared.removeAllCachedResponses()
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
self.onboardOrRestore()
}
}
}
}
func unregister() {
OnboardingFlowController.reset(on: self.restoringSteps, context: myContext) {
URLCache.shared.removeAllCachedResponses()
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
UserDefaults.standard.set(nil, forKey:"userOnboardingID")
self.onboardOrRestore()
}
}
func getAppConfig() {
var host = ""
if let path = Bundle.main.path(forResource: "ConfigurationProvider", ofType: "plist") {
let myDict = NSDictionary(contentsOfFile: path)
appId = myDict?.object(forKey: "appId") as! String
authPath = myDict?.object(forKey: "authPath") as! String
host = myDict?.object(forKey: "host") as! String
}
serviceURL = URL.init(string: "https://\(host)/\(authPath)")!
}
getAppConfig()
UINavigationBar.applyFioriStyle()
onboardOrRestore()
step.defaultPasscodePolicy = nil
//use values published in the discovery service.
let welcomeScreenStep = WelcomeScreenStep(transformer: discoveryConfigurationTransformer, providers: [DiscoveryServiceConfigurationProvider(applicationID: appId)])
https://discovery.sapmobilesecure.com/config-api.svc/ApplicationConfigurations/getApplicationConfiguration(AppConfigID='com.iossdk.gs:1.0',EmailAddress='dan@trial-pXXXXXXXtrial.sapmobileplace.com')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
10 | |
9 | |
8 | |
8 | |
8 | |
7 |