开发中的APP,不做任何处理,点击弹出的快捷方式。
上线的APP,不做任何处理,点击弹出的快捷方式。
自定义快捷方式
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
setupShortcutItems()
}
import Foundation
extension AppDelegate {
func setupShortcutItems() {
let searchIcon = UIApplicationShortcutIcon(type: .search)
let searchItem = UIApplicationShortcutItem(type: "search", localizedTitle: "搜索", localizedSubtitle: nil, icon: searchIcon, userInfo: nil)
let messageIcon = UIApplicationShortcutIcon(type: .message)
let messageItem = UIApplicationShortcutItem(type: "message", localizedTitle: "消息", localizedSubtitle: "消息子标题", icon: messageIcon, userInfo: nil)
UIApplication.shared.shortcutItems = [searchItem, messageItem]
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if (shortcutItem.type == "search") {
print("进入搜索")
} else if (shortcutItem.type == "message") {
print("进入消息")
}
}
}