dependencies: [
.package(url: "https://github.com/VKCOM/vkid-ios-sdk.git", .upToNextMajor(from: "2.7.1"))
]
pod 'VKID', '~> 2.3'
pod install --repo-update
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vkauthorize-silent</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>auth_callback</string>
<key>CFBundleURLSchemes</key>
<array>
<string>vk123456</string> // Вместо 123456 подставьте ID вашего приложения.
</array>
</dict>
</array>
import VKID
do {
try VKID.shared.set(
config: Configuration(
appCredentials: AppCredentials(
clientId: clientId, // ID вашего приложения.
clientSecret: clientSecret // ваш защищенный ключ (client_secret).
),
loggingEnabled: false // Включите логи для отладки.
)
)
} catch {
preconditionFailure("Failed to initialize VKID: \(error)")
}
// Настройка при инициализации SDK.
let vkid = try VKID.shared.set(
config: Configuration(
appCredentials: AppCredentials(
clientId: clientId,
clientSecret: clientSecret
),
appearance: .init(
locale: .ru
)
)
)
// Настройка после инициализации SDK: вы можете сменить локаль на другую.
VKID.shared.appearance.locale = .en
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
return VKID.shared.open(url: url)
}
func scene(
_ scene: UIScene,
openURLContexts URLContexts: Set<UIOpenURLContext>
) {
URLContexts.forEach { ctx in
VKID.shared.open(url: ctx.url)
}
}
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
_ = VKID.shared..open(url: url)
}
}
}