Closed D-Link13 closed 7 years ago
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let vkSDK = VKSdk.initialize(withAppId: VKNetworking.kVK_APP_ID) vkSDK?.register(VKNetworking.shared) vkSDK?.uiDelegate = VKNetworking.shared return true }
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { VKSdk.processOpen(url, fromApplication: sourceApplication) return true }
class VKNetworking: NSObject { static let shared = VKNetworking() static let kVK_APP_ID = "" let permissions = NSArray(objects: "email", "wall") as [AnyObject] var userEmail = String() func vkLogin(completion: @escaping (Bool) -> ()) { VKSdk.wakeUpSession(self.permissions, complete: { (state, error) in if state == .authorized && error == nil && VKSdk.accessToken() != nil { print("vk authorized") completion(true) } else if state == .initialized { print("vk initialized") VKSdk.authorize(self.permissions) } else { if error != nil { print(error!) } completion(false) } }) } } extension VKNetworking: VKSdkDelegate { func vkSdkAccessAuthorizationFinished(with result: VKAuthorizationResult!) { if result.token != nil && result.error == nil { if let email = result.token.email { self.userEmail = email } } } func vkSdkUserAuthorizationFailed() { print("vkSdkUserAuthorizationFailed") } }
проблема решена, не была настроена url схема