Great question!

First, how to get the link that the app was launched from, if any.

Answer: Inside your struct, implement the view modifier on :

Here, we have a property, which is synced with using (I go in depth about that here).

This is what ContentView looks like:

It displays a that shows the link (I used a URL scheme, called ) that the app was launched from. And if the app was not launched from a link, it displays the placeholder.

Left: when launched from a link. Right: when launched directly from the home screen.

Because a property updates automatically, is able to replace both of the functions from SceneDelegate — in SwiftUI, you don’t need a separate function for loading the url on first launch, and another one for loading the url after coming back from the background.

You can get more information about here.

Second, how to monitor device rotation

Answer: There’s a lot of ways to do this, but the easiest is to use a notification publisher. Here’s what ContentView will look like:

Source from Koraktor’s great Stack Overflow answer

Result:

Basically, we’re combining ’s Notification Center with ’s Publisher ( and are frameworks). You can check this out for more information on Notification Publishers.

WWDC21 Scholar. I like to read manga and write about Swift. Check out my app, Find — look for text in real life, with outrageous speed. getfind.app

WWDC21 Scholar. I like to read manga and write about Swift. Check out my app, Find — look for text in real life, with outrageous speed. getfind.app