Skip to content

Instantly share code, notes, and snippets.

@aheze
Created June 30, 2020 02:28
Show Gist options
  • Select an option

  • Save aheze/5e796a12a12307c4c4e5c23904899a00 to your computer and use it in GitHub Desktop.

Select an option

Save aheze/5e796a12a12307c4c4e5c23904899a00 to your computer and use it in GitHub Desktop.
import SwiftUI
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
if shortcutItem.type == "com.example.ExampleApp.exampleAction" {
print("Action Pressed!")
}
}
return true
}
}
@main
struct SwiftUI_AppApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment