ios - VK iOS sdk授权

标签 ios swift sdk vk

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

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 VKSdk.autorize(...) 返回此错误:

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"

最佳答案

我通过添加到 Info.plist 来修复这个错误

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>vkauthorize</string>
</array>

关于ios - VK iOS sdk授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31118600/

相关文章:

java - 如何从 APi.ai 的 Java SDK 获取 Json

objective-c - 读取本地 html 文件并在 webview 上显示

ios - 无法更新 .geojson 文件以在 App Store 上提交应用程序

android - 如果我只需要一个 webview,PhoneGap 是不是太多了?

ios - 为什么 PHAssetCollection 计数为 0?

ios - Alamofire http json 请求 block ui

generics - 如何在 Swift 泛型中说 "same class"

ios - 循环坐标并找到距离 Swift 3 点最近的商店

java - 尝试为 onKeyDown 事件创建自己的方法(Android)

java - 我的 android studio 显示错误