Expose commonly used functionality with static or dynamic 3D Touch Home Screen quick actions.
On the Home screen of a device running iOS 13 or later, apps can display Home Screen quick actions when users touch and hold the app icon (on a 3D Touch device, users press briefly on the icon)
Apple Developer website: https://developer.apple.com/sf-symbols
1 . Export > choose destination folder for exported templated
2 . Copy files that were exported into your project’s assets
Use these icons as values for the UIApplicationShortcutItemIconFile field inside the app icon section of the Info.plist(static quick actions)
UIApplicationShortcutItemType (required):
A unique string that identifies the Quick Action. For example: com.mediumproject.helloWorld.
UIApplicationShortcutItemTitle (required):
The Quick Action title displayed to the user.
UIApplicationShortcutItemSubtitle (optional):
The Quick Action’s subtitle.
UIApplicationShortcutItemIconType (optional):
Here you can set a predefined icon made by Apple.
UIApplicationShortcutItemIconFile (optional):
Use to set a custom icon.
UIApplicationShortcutItemUserInfo (optional):
A dictionary to save data.
func sceneWillResignActive(_ scene: UIScene) {
let application = UIApplication.shared
application.shortcutItems = [
UIApplicationShortcutItem(type: "trash", localizedTitle: "Trash", localizedSubtitle: nil, icon: UIApplicationShortcutIcon(systemImageName: "trash.slash.circle"))]
}
func windowScene(_ windowScene: UIWindowScene,
performActionFor shortcutItem: UIApplicationShortcutItem,
completionHandler: @escaping (Bool) -> Void) {
switch shortcutItem.type {
case "send", "trash":
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()) {
self.window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
let alert = UIAlertController(title: "Hey", message: "Your quick action works!", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
}
default: break
}
}