TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Launch app from website link

Forums > macOS

Good morning

Looking for a way to launch my psotal service barcode app from an URL and found this page:

http://www.gietal.net/blog/launch-macos-app-from-url

But this describes an old method using AppDelegate....

Would this have to use now as well this snippet like for push notifications?

@main
struct WedernochApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    var body: some Scene {
        WindowGroup {
            MainView()
        }
    }
}

3      

Ah no...there is no AppDelegateAdaptor for macOS.....

Is there another method to add Apple Event receiver for URLScheme?

3      

Ah no...there is no AppDelegateAdaptor for macOS.....

There is: NSApplicationDelegateAdaptor | Apple Developer Documentation

3      

Right...forgot the good old NextStep workstation I had (o;

So this just works fine:

@main
struct BarcoderApp: App {
    @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate
    var body: some Scene {
        WindowGroup {
            ContentView()

        }
        Settings {
          PreferencesView()
        }
    }
}

class AppDelegate: NSObject, NSApplicationDelegate {
    open func applicationWillFinishLaunching(_ notification: Notification) {
        print("Will Finish Launching")
    }
}

And YESSS...Safari can launch now my Barcoder App ;-)

Now onto parsing URL parameters....

3      

Hmm...looks good.....

klingler@Mac-mini-Arbeitszimmer ~ % /Applications/Barcoder.app/Contents/MacOS/Barcoder
Will Finish Launching
["lastname": "klingler", "firstname": "richard"]

3      

Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.