gpt4 book ai didi

swift - SMP SDK for iOS 用于 Swift 开发

转载 作者:行者123 更新时间:2023-11-28 07:45:29 28 4
gpt4 key购买 nike

ios开发(Swift语言)如何通过sdk连接SMP服务器

我修改了示例 odataconnection 文件,其中包含必要的配置,如连接、主机、端口和域以及安全配置文件。但那是基于 objectiveC 的。

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

谢谢,拉杰卡马尔

最佳答案

您尝试过我们的Tutorials吗?然而?本质上,您需要的是一组正确的连接设置:

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

关于swift - SMP SDK for iOS 用于 Swift 开发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51150167/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com