GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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      

Go further, faster with the Swift Career Accelerator.

GO FURTHER, FASTER Unleash your full potential as a Swift developer with the all-new Swift Career Accelerator: the most comprehensive, career-transforming learning resource ever created for iOS development. Whether you’re just starting out, looking to land your first job, or aiming to become a lead developer, this program offers everything you need to level up – from mastering Swift’s latest features to conquering interview questions and building robust portfolios.

Learn more here

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.