SFSafariViewController behaves differently in MacCatalyst than iOS

I was loading a URL using SFSafariViewController in my app and also implemented the SFSafariViewControllerDelegate. I noticed that when I am running my app on iOS, I am not getting the callBack in safariViewControllerDidFinish(_:) until or unless "Done" button is pressed. But when I am running it on MacCatalyst following behaviour is noticed:

  1. default browser is launched.
  2. I get a callback in safariViewControllerDidFinish(_:) without any of my action(like pressing "Done" button).

Is this the expected behaviour? I am curious to know why I am getting callback in safariViewControllerDidFinish(_:).

Replies

Expected behavior still sadly. From the docs:

When building apps to support multiple platforms, be aware of behavior differences when presenting an SFSafariViewController from your UI. In Mac apps built with Mac Catalyst, and in compatible iPad and iPhone apps running in visionOS, showing an SFSafariViewController opens the web content in the default web browser instead.

You might want to fall back to WKWebView in those scenarios.