stleamist / BetterSafariView

A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.
MIT License
581 stars 57 forks source link

Programmatic URL navigation and dismissal #11

Closed jefflaporte closed 1 year ago

jefflaporte commented 3 years ago

Is there any current way to update the URL for, or programmatically dismiss an already displayed SafariView? I've tried a number of ways to do this but haven't been able to make it work.

The use case is handling taps arriving from a Widget Extension in .onOpenURL(), and updating the URL accordingly.

Thanks for building the package!

jefflaporte commented 3 years ago

It seems from SafariViewPresenter.Coordinator.handleItemChange() that the intention was for the lib to dismiss and load on a URL change:

    case let (.some(oldItem), .some(newItem)) where oldItem.id != newItem.id:
        dismissSafariViewController() {
            self.presentSafariViewController(with: newItem)
        }

For some reason updating the URL via the view modifier doesn't seem to trigger dismissal.