I am trying to get an Instagram authentication token for an app Im working on, I have the app opening safari, Im able to log in and then it send me back to the app, but when it transfers me back to the app, handleOpenURL is not triggering in AppDelegate. Here is a sample of my code:
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
}
}
and here is a my API Manager code that is triggering safari to open:
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)
}
}
....
}
Any help would be appreciated!
In iOS 9, application:handleOpenURL:
is deprecated. Instead, you should be using:
func application(app: UIApplication,
openURL url: NSURL, options: [String : AnyObject]) -> Bool {