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 String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.