VKCOM / vk-ios-sdk

iOS library for working with VK API, authorization through VK app, using VK functions
MIT License
298 stars 165 forks source link

swift 3.0 VKSdk.processOpen return false #477

Open ghost opened 7 years ago

ghost commented 7 years ago

while i try to authorize user after success initialize and register of my VKSdk.processOpen function in AppDelegate always return false, but when i open url in safari all is done(with false).

my AppDelegate:

static let VKAppId = "5784789"

 func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        let ret: Bool = VKSdk.processOpen(url, fromApplication: sourceApplication)
        print(ret)
        return true
    }

myController:

class MyController: UIViewController {
    private let vkPerm = [VK_PER_FRIENDS]
    override func viewDidLoad() {
        super.viewDidLoad()

        let instance = VKSdk.initialize(withAppId: AppDelegate.VKAppId)
        instance?.register(self)
        instance?.uiDelegate = self

        VKSdk.wakeUpSession(vkPerm, complete: { (state, error) in
            if (state ==  VKAuthorizationState.authorized) {
                print("wakeUpSession")
            } else {
                VKSdk.authorize(self.vkPerm, with: .disableSafariController)
            }
        })
    }

extension MyController: VKSdkDelegate, VKSdkUIDelegate {

    func vkSdkNeedCaptchaEnter(_ captchaError: VKError) {
        print(captchaError)
    }

    func vkSdkTokenHasExpired(expiredToken: VKAccessToken) {

    }

    func vkSdkUserDeniedAccess(authorizationError: VKError) {

    }

    func vkSdkReceivedNewToken(newToken: VKAccessToken) {
        UserDefaults.standard.set(newToken, forKey: TOKEN_KEY)
        UserDefaults.standard.synchronize()
        print(newToken)
    }

    func vkSdkAccessAuthorizationFinished(with result: VKAuthorizationResult!) {
        print("gg")
    }

    func vkSdkUserAuthorizationFailed() {
        print("lol")
    }
    func vkSdkShouldPresent(_ controller: UIViewController!) {
        self.present(controller, animated: true, completion: nil)
    }

}

my Info.plist:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>vk5784789</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>vkauthorize</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>vk</string>
        <string>vk-share</string>
        <string>vkauthorize</string>
    </array>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>vk.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
        </dict>
    </dict>
suzhaev commented 7 years ago

@MrNoobody Please send us a sample project that can reproduce the same problem

ghost commented 7 years ago

@suzhaev VKIntegration.zip