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"
I fix this error with adding to Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>vkauthorize</string>
</array>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With