From dabe46e52e1725efe0ca510c9ec4ff814a26b3ed Mon Sep 17 00:00:00 2001 From: Nikita Lutsenko Date: Wed, 3 Aug 2016 12:52:17 -0700 Subject: [PATCH] Add iOS 9.0+ method for opening URLs to ApplicationDelegate. --- Samples/Catalog/Sources/AppDelegate.swift | 5 +++++ Sources/Core/Common/ApplicationDelegate.swift | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Samples/Catalog/Sources/AppDelegate.swift b/Samples/Catalog/Sources/AppDelegate.swift index 2f9d1518..c9a53cfc 100644 --- a/Samples/Catalog/Sources/AppDelegate.swift +++ b/Samples/Catalog/Sources/AppDelegate.swift @@ -40,6 +40,11 @@ extension AppDelegate: UIApplicationDelegate { annotation: annotation) } + @available(iOS 9.0, *) + func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { + return SDKApplicationDelegate.shared.application(application, openURL: url, options: options) + } + func applicationDidBecomeActive(application: UIApplication) { AppEventsLogger.activate(application) } diff --git a/Sources/Core/Common/ApplicationDelegate.swift b/Sources/Core/Common/ApplicationDelegate.swift index ee3a9c0d..7b197a97 100644 --- a/Sources/Core/Common/ApplicationDelegate.swift +++ b/Sources/Core/Common/ApplicationDelegate.swift @@ -65,4 +65,23 @@ extension ApplicationDelegate { public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { return delegate.application(application, openURL:url, sourceApplication:sourceApplication, annotation:annotation) } + + /** + Call this function from the `UIApplicationDelegate.application(app:openURL:options:)` function of the AppDelegate for your app. + It should be invoked for the proper processing of responses during interaction + with the native Facebook app or Safari as part of SSO authorization flow or Facebook dialogs. + + - parameter application: The application as passed to `UIApplicationDelegate`. + - parameter url: The URL as passed to `UIApplicationDelegate`. + - parameter options: The options as passed to `UIApplicationDelegate`. + + - returns: `true` if the url was intended for the Facebook SDK, otherwise - `false`. + */ + @available(iOS 9.0, *) + public func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { + return delegate.application(application, + openURL: url, + sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String, + annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) + } }