This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol DeeplinkHandlerProtocol { | |
func handle(url: URL, completion:DeeplinkHandlerCompletion?) -> Bool | |
func handle(customScheme url: URL, completion:DeeplinkHandlerCompletion?) -> Bool | |
func handle(userActivity: NSUserActivity, completion:DeeplinkHandlerCompletion?) -> Bool | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool { | |
let dynamicLinkHandler = FirebaseDynamicLinksHandler() | |
let handled = dynamicLinkHandler.handle(customScheme: url) { (success) in | |
AppStateController.shared().deeplinkCallbackCompleted = true | |
} | |
return handled | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handle(customScheme url: URL, completion:DeeplinkHandlerCompletion?) -> Bool { | |
let dynamicLink = DynamicLinks.dynamicLinks()?.dynamicLink(fromCustomSchemeURL: url) | |
guard (dynamicLink?.url) != nil else { | |
completion?(false) | |
return false | |
} | |
self.storeDynamicLink(dynamicLink!) | |
completion?(true) | |
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We stored so we can later do whatever me need with them. | |
func storeDynamicLink(_ dynamicLink: DynamicLink) { | |
guard let url = dynamicLink.url else { return } | |
guard let urlString = url.valueOf( | |
queryParamaterName: "url") else { return } | |
var data: [String:Any] = [:] | |
data["firebase.deeplink.url"] = urlString | |
UserDefaults.standard.set(data, forKey: Params.storageKey.rawValue) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { | |
self.currentUserActivity = userActivity | |
let dynamicLinkHandler = FirebaseDynamicLinksHandler() | |
let handled = dynamicLinkHandler.handle(userActivity: userActivity) { (success) in | |
///callback completed should update the startup state | |
AppStateController.shared().deeplinkCallbackCompleted = true | |
} | |
return handled | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handle(userActivity: NSUserActivity, completion:DeeplinkHandlerCompletion?) -> Bool { | |
guard let url = userActivity.webpageURL else { return false } | |
let handled = self.handle(url: url, completion: completion) | |
return handled | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
currentUserActivity = LaunchOptionsHandler.handle(launchOptions: launchOptions) | |
FirebaseApp.configure() | |
flowCoordinator.start { (error) in | |
} | |
return true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct LaunchOptionsHandler { | |
static func handle(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> NSUserActivity? { | |
if let activityType = launchOptions?[.userActivityType] as? String { | |
if activityType == NSUserActivityTypeBrowsingWeb { | |
return NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb) | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum StartupState { | |
case authenticated, deeplink, unauthenticated | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate var isCurrentUserActivity:Bool { | |
get { | |
let appDelegte = UIApplication.shared.delegate as! AppDelegate | |
return appDelegte.currentUserActivity != nil | |
} | |
} | |
OlderNewer