Skip to content

Commit

Permalink
ios platform deep link
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Oct 5, 2023
1 parent f9ff181 commit 283f0fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Photos
WidgetkitPlugin.bind(controller: controller)
DocumentPlugin.bind(controller:controller)
GeneratedPluginRegistrant.register(with: self)
DeepLinkPlugin.register(with: self)
DeepLinkPlugin.register(with: self.registrar(forPlugin: "DeepLinkPlugin")!)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

Expand Down
5 changes: 4 additions & 1 deletion ios/Runner/DeepLinkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ class DeepLinkPlugin : NSObject, FlutterPlugin, FlutterStreamHandler {
let url = launchOptions[UIApplication.LaunchOptionsKey.url] as? URL
initialLink = url?.absoluteString
latestLink = initialLink
eventSink?(latestLink)
return true
}

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
latestLink = url.absoluteString
eventSink?(latestLink)
return true
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
self.latestLink = userActivity.webpageURL?.absoluteString
if eventSink != nil {
eventSink?(latestLink)
if eventSink == nil {
self.initialLink = self.latestLink
}
return true
Expand Down

0 comments on commit 283f0fe

Please sign in to comment.