4

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"

Valentin Shamardin
  • 3,569
  • 4
  • 34
  • 51
nickaroot
  • 317
  • 2
  • 12
  • 1
    Sounds like an error produced on vk.com side. Don't you have to register your app somehow to be allowed to make requests? – 0x416e746f6e Jun 29 '15 at 15:02

1 Answers1

17

I fix this error with adding to Info.plist

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>vkauthorize</string>
</array>
nickaroot
  • 317
  • 2
  • 12