gpt4 book ai didi

ios - VK iOS sdk授权

转载 作者:搜寻专家 更新时间:2023-10-31 08:12:01 25 4
gpt4 key购买 nike

我正在尝试在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com