From 96665c48e1da48f98a978f5202f4083f98f3cf0e Mon Sep 17 00:00:00 2001 From: Nikita Lutsenko Date: Mon, 8 Aug 2016 12:57:04 -0700 Subject: [PATCH] Add iOS 9.0+ method for opening URLs to ApplicationDelegate. (#37) --- Samples/Catalog/Sources/AppDelegate.swift | 5 +++++ .../Core/Common/SDKApplicationDelegate.swift | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Samples/Catalog/Sources/AppDelegate.swift b/Samples/Catalog/Sources/AppDelegate.swift index 3fdb4924..c86be6f8 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/SDKApplicationDelegate.swift b/Sources/Core/Common/SDKApplicationDelegate.swift index 22fc7c8c..51f7545f 100644 --- a/Sources/Core/Common/SDKApplicationDelegate.swift +++ b/Sources/Core/Common/SDKApplicationDelegate.swift @@ -62,7 +62,27 @@ extension SDKApplicationDelegate { - returns: `true` if the url was intended for the Facebook SDK, otherwise - `false`. */ + @available(iOS, deprecated=9.0, message="Please use application:openURL:options:") 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]) + } }