swift - SMP SDK for iOS 用于 Swift 开发

标签 swift sap-smp

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/

相关文章:

swift - 一个函数返回另一个函数的好例子是什么?

ios - AVPlayer 不播放 HLS 流

swift - 为什么我在此代码中收到 "missing argument for parameter"错误?

swift - Swift 中 EXCEL 的 RATE 函数提供不同的结果

android - SMP 与 Android 的集成

android - 使用 Proguard 为 Android 应用程序混淆 SMP 库

ios - AppDelegate.swift 中没有这样的模块 'AWSMobileClient' 错误