@import SberbankSDK;
import SberbankSDK
SBKLoginButton *loginButton = [[SBKLoginButton alloc] initWithType:SBKLoginButtonGreen];
[loginButton addTarget:self action:@selector(loginButtonDidTap:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:loginButton];
let loginButton = SBKLoginButton(type: .white)
loginButton.addTarget(self, action: #selector(loginButtonDidTap(_:)), for: .touchUpInside)
view.addSubview(loginButton)
// Параметры для поддержки PKCE
NSString *verifier = [SBKUtils createVerifier];
NSString *challenge = [SBKUtils createChallenge:verifier];
SBKAuthRequest *request = [SBKAuthRequest new];
request.clientId = @"you cliend id";
request.nonce = @"you nonce";
request.scope = @"you scope";
request.state = @"you state";
request.redirectUri = @"myapp://sberidauth";
request.codeChallenge = challenge;
request.codeChallengeMethod = SBKUtilsCodeChallengeMethod;
// Запуска аутентификации
SBKAuthManager *authManager = [SBKAuthManager new];
[authManager authWithSberId:request];
// Параметры для поддержки PKCE
let verifier = SBKUtils.createVerifier()
let challenge = SBKUtils.createChallenge(verifier)
let request = SBKAuthRequest()
request.clientId = "you client id"
request.nonce = "you nonce"
request.scope = "you scope"
request.state = "you state"
request.redirectUri = "myapp://sberidauth"
request.codeChallenge = challenge
request.codeChallengeMethod = SBKUtilsCodeChallengeMethod
// Запуск аутентификации
let authManager = SBKAuthManager()
authManager.auth(withSberId: request)
<key>LSApplicationQueriesSchemes</key>
<array>
<string>sberbankidexternallogin</string>
</array>
// Для iOS 9+
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { return YES; }
// Для iOS < 9
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return YES; }
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { return true }
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
if ([url.scheme isEqualToString:@"myapp"] && [url.host isEqualToString:@"sberidauth"])
{
[[SBKAuthManager new] getResponseFromURL:url completion:^(SBKAuthResponse *response) {
}];
}
return YES;
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.scheme == "myapp" && url.host == "sberidauth" {
SBKAuthManager().getResponseFrom(url) { response in
}
}
return true
}