1

How to establish connection to SMP server through sdk for ios development (Swift language).

I have sample odataconnection file modified with necessary configurations like connection, host, port and domain and security profile. But that is for objectiveC based.

Requesting similar sample code for swift so that I can establish device registration and user logon in SMP

Thanks, Rajkamal

Michael Jess
  • 1,907
  • 1
  • 19
  • 17
Raj
  • 11
  • 2

1 Answers1

0

Have you tried our Tutorials yet? Essentially, what you need is the right set of connection settings:

struct Constants {
    // The appID is the unique identifier of the application.
    // It must be the the same ID as on the server, but it may be different
    // from the bundle identifier of your application.
    //  static let appID = "com.sap.mit.native.intermediate.logon"
    private static let sapcpmsURLString = "https://mobile-a326aab34.hana.ondemand.com/"
    static let sapcpmsURL = URL(string: sapcpmsURLString)!
    static let appURL = sapcpmsURL.appendingPathComponent(appID)
    static let samlAuthURL = URL(string: "\(sapcpmsURL.absoluteString)SAMLAuthLauncher")!
    static let samlFinishURL = URL(string: "\(sapcpmsURL.absoluteString)SAMLAuthLauncher?finishEndpointParam=someUnusedValue")!
}

Then register as follows (assuming SAML authentication):

public func authenticate(completionHandler: @escaping (_ error: Error?) -> Void) {
    // this starts a SAML authentication against the SAP Cloud Platform if successfull it will be registered to the current urlSession
    // let samlAuthenticationParameters = SAMLAuthenticationParameters(authorizationEndpointURL: Constants.samlAuthURL, finishEndpointURL: Constants.samlFinishURL)
    let samlAuthenticator = SAMLAuthenticator(authenticationParameters: samlAuthenticationParameters)
    let samlObserver = SAMLObserver(authenticator: samlAuthenticator)
    urlSession.register(samlObserver)

    samlAuthenticator.authenticate(completionHandler: completionHandler)
}
Michael Jess
  • 1,907
  • 1
  • 19
  • 17
  • Thanks for your reply Michael.. we are using SMP3.0 sp14.. not Cloud platform mobile service.. Do you see any issue in this? – Raj Jul 03 '18 at 12:42
  • The iOS SDK is compatible with both. You just need to adjust the URL and authentication scheme to match your SMP server configuration. – Michael Jess Jul 03 '18 at 15:45