Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
汉德利奥佩努尔元';t触发iOS Swift 2_Ios_Swift2_Instagram Api - Fatal编程技术网

汉德利奥佩努尔元';t触发iOS Swift 2

汉德利奥佩努尔元';t触发iOS Swift 2,ios,swift2,instagram-api,Ios,Swift2,Instagram Api,我正在尝试为我正在使用的应用程序获取Instagram身份验证令牌,我有应用程序打开safari,我可以登录,然后它会将我发送回应用程序,但当它将我传输回应用程序时,AppDelegate中不会触发handleOpenURL。以下是我的代码示例: import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? .... func

我正在尝试为我正在使用的应用程序获取Instagram身份验证令牌,我有应用程序打开safari,我可以登录,然后它会将我发送回应用程序,但当它将我传输回应用程序时,AppDelegate中不会触发handleOpenURL。以下是我的代码示例:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

....
    func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
        InstagramAPIManager.sharedInstance.processOAuthStep1Response(url)
        print(url)
        print("handleOpenURL")
        return true
    }

}
下面是触发safari打开的my API Manager代码:

import Foundation
import Alamofire

class InstagramAPIManager {
    static let sharedInstance = InstagramAPIManager()

    func startOAuth2Login() {
        let clientID: String = "abcdefg"
        let authPath:String = "https://api.instagram.com/oauth/authorize/?client_id=\(clientID)&redirect_uri=grokInstagram://?aParam=paramVal&response_type=code"
        if let authURL:NSURL = NSURL(string: authPath)
        {
            UIApplication.sharedApplication().openURL(authURL)
        }
    }
....

}

任何帮助都将不胜感激

在iOS 9中,
应用程序:handleOpenURL:
不推荐使用。相反,您应该使用:

func application(app: UIApplication, 
    openURL url: NSURL, options: [String : AnyObject]) -> Bool {

正确的语法似乎是

func application(_ app: UIApplication,
                          open url: URL,
                          options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    return true
}

根据

你知道
handleOpenURL:
不受欢迎,对吧?在iOS 9中,您应该使用
func应用程序(app:UIApplication,openURL:NSURL,options-options:[String:AnyObject])->Bool
我不知道,谢谢!非常好,非常感谢!那我就回答你。很高兴它成功了!如果安装在Instagram应用程序上,我如何从中获取OAuth2令牌?哦,还有,您已经编写了两次“option”,并且抛出了一个错误,但是Xcode修复了它。