SMP SDK for iOS 用于在 Swift 上进行开发



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

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

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

谢谢,拉杰卡马尔

你试过我们的教程吗?从本质上讲,您需要的是一组正确的连接设置:

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

最新更新