VK iOS sdk授权

时间:2015-06-29 14:41:22

标签: ios swift sdk vk

我正在尝试在Swift 2.0项目中设置VK iOS SDK。我收到错误,我不知道为什么会这样。

AppDelegate.swift

grep '^not found' file
not found
not found

ViewController.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
    }

}

Bridgind Header.h

//
//  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.
    }
}

使用// // -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" 自动调整会返回此错误:

  

2015-06-29 16:11:14.931 iosVKMusic [554:75899] -canOpenURL:网址失败:“vkauthorize:// authorize” - 错误:“此应用不允许查询方案vkauthorize”

1 个答案:

答案 0 :(得分:14)

我通过添加到Info.plist

来解决此错误
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>vkauthorize</string>
</array>