1

如何通过 sdk 建立与 SMP 服务器的连接以进行 ios 开发(Swift 语言)。

我使用必要的配置(如连接、主机、端口和域以及安全配置文件)修改了示例 odataconnection 文件。但那是基于objectiveC的。

为 swift 请求类似的示例代码,以便我可以在 SMP 中建立设备注册和用户登录

谢谢, 拉杰卡马尔

4

1 回答 1

0

您是否尝试过我们的教程?本质上,您需要的是正确的连接设置集:

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")!
}

然后注册如下(假设SAML认证):

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)
}
于 2018-07-03T11:23:09.220 回答