FormsHomeShortcuts is shortcuts helper.
import FormsHomeShortcuts
public enum DemoHomeShortcutsKeys: String, CaseIterable, HomeShortcutsKeysProtocol {
case option1
case option2
public var item: HomeShortcutItem {
let bundleIdentifier: String = Bundle.main.bundleIdentifier ?? ""
switch self {
case .option1:
return HomeShortcutItem(
bundleIdentifier: bundleIdentifier,
code: "opt_1",
title: "Title option 1",
subtitle: "Subtitle option 1",
icon: UIApplicationShortcutIcon(systemImageName: "square.and.arrow.up"),
userInfo: nil)
case .option2:
return HomeShortcutItem(
bundleIdentifier: bundleIdentifier,
code: "opt_2",
title: "Title option 2",
subtitle: "Subtitle option 2",
icon: UIApplicationShortcutIcon(systemImageName: "paperplane.fill"),
userInfo: nil)
}
}
}
let homeShortcuts = HomeShortcuts()
homeShortcuts.add(keys: DemoHomeShortcutsKeys.allCases)
let homeShortcuts = HomeShortcuts()
homeShortcuts.removeAll()
In app delegate didFinishLaunchingWithOptions
homeShortcuts.launch(launchOptions)
and
func application(_ application: UIApplication,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void) {
homeShortcuts.launch(shortcutItem)
completionHandler(true)
}
In scene delegate connectionOptions
homeShortcuts.launch(connectionOptions.shortcutItem)
and
func windowScene(_ windowScene: UIWindowScene,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void) {
homeShortcuts.launch(shortcutItem)
completionHandler(true)
}
homeShortcuts.handleIfNeeded { (item: UIApplicationShortcutItem) in }