Skip to content

Instantly share code, notes, and snippets.

@jezell
Created June 8, 2024 00:14
Show Gist options
  • Save jezell/8a6b4c7bf61916ffc03a0245a9e99c85 to your computer and use it in GitHub Desktop.
Save jezell/8a6b4c7bf61916ffc03a0245a9e99c85 to your computer and use it in GitHub Desktop.
import UIKit
import Flutter
import app_links
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
if let url = AppLinks.shared.getLink(launchOptions: launchOptions) {
// We have a link, propagate it to your Flutter app
AppLinks.shared.handleLink(url: url)
return true
}
super.application(application, didFinishLaunchingWithOptions: launchOptions)
return false
}
override func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
let url = userActivity.webpageURL
AppLinks.shared.handleLink(url: url!)
return true
}
return false
}
override func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
) -> Bool {
AppLinks.shared.handleLink(url: url)
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment