SMP SDK для iOS для разработки на Swift
Как установить соединение с SMP-сервером через SDK для разработки IOS (язык Swift).
У меня есть образец файла odataconnection, модифицированный необходимыми конфигурациями, такими как соединение, хост, порт и домен и профиль безопасности. Но это для объективного C на основе.
Запрос аналогичного примера кода для swift, чтобы я мог установить регистрацию устройства и вход пользователя в систему SMP
Спасибо, Райкамал
1 ответ
Вы уже пробовали наши уроки? По сути, вам нужен правильный набор настроек соединения:
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)
}