Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VK iOS sdk authorize

Tags:

ios

swift

sdk

vk

I'm trying to setup VK iOS SDK in a Swift 2.0 project. I'm getting an error and I don't have any idea why it occurs.

AppDelegate.swift:

//
//  AppDelegate.swift
//  iosVKMusic
//
//  Created by Nick on 25.06.15.
//  Copyright © 2015 Funtrum. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
        let ret:Bool = VKSdk.processOpenURL(url, fromApplication: sourceApplication)
        return ret
    }

}

ViewController.swift:

//
//  ViewController.swift
//  iosVKMusic
//
//  Created by Nick on 25.06.15.
//  Copyright © 2015 Funtrum. All rights reserved.
//

import UIKit

extension ViewController: VKSdkDelegate {
    func vkSdkNeedCaptchaEnter(captchaError: VKError) { }
    func vkSdkTokenHasExpired(expiredToken: VKAccessToken) { }
    func vkSdkUserDeniedAccess(authorizationError: VKError) { }
    func vkSdkShouldPresentViewController(controller: UIViewController) { }
    func vkSdkReceivedNewToken(newToken: VKAccessToken) { }
}

class ViewController: UIViewController {

    let TOKEN_KEY = "my_application_access_token"

    override func viewDidLoad() {
        super.viewDidLoad()
        VKSdk.initializeWithDelegate(self, andAppId: "4314639")
    }

    @IBAction func authTouchUp(sender: UIButton) {
        if (VKSdk.wakeUpSession()) {
            print("wakeUpSession", appendNewline: true)
        } else {
            print("else", appendNewline: true)
            VKSdk.authorize([VK_PER_AUDIO, VK_PER_OFFLINE], revokeAccess: true)
        }
    }

    func vkSdkAcceptedUserToken(token: VKAccessToken!) {
        print("ACCEPTED", appendNewline: true)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

Bridgind Header.h:

//
//  -Bridging-Header.h
//  iosVKMusic
//
//  Created by Nick on 28.06.15.
//  Copyright © 2015 Funtrum. All rights reserved.
//

#ifndef _Bridging_Header_h
#define _Bridging_Header_h


#endif /* _Bridging_Header_h */

#import "VKSdk.h"

Autorize with VKSdk.autorize(...) returns this error:

2015-06-29 16:11:14.931 iosVKMusic[554:75899] -canOpenURL: failed for URL: "vkauthorize://authorize" - error: "This app is not allowed to query for scheme vkauthorize"

like image 340
nickaroot Avatar asked Dec 02 '22 16:12

nickaroot


1 Answers

I fix this error with adding to Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>vkauthorize</string>
</array>
like image 57
nickaroot Avatar answered Dec 30 '22 04:12

nickaroot