Ive been through all the other questions and I can't figure out what's wrong.
I downloaded the sample project from the Apple Developer site Add Home Screen Quick Actions and that works no problem, but when I start a new Xcode project and copy that exactly it doesn't work for me. I must be missing something. At this point I just want it to print in the console saying "shortcut pressed". When I add print("Shortcut pressed")
to the Apple project I downloaded it works fine.
At this point I am just trying random things.
I updated my info.plist with an Array and a dictionary and strings and I just copy and past the values as to not make any typo mistakes.
UIApplicationShortcutItems, Item 0, UIApplicationShortcutItemType, UIApplicationShortcutItemIconType, UIApplicationShortcutItemTitle
The shortcut appears when pressing the app icon but it just opens the app.
This is my very basic AppDelegate.Swift file just trying to get it to do anything Could it be my project settings, my version of Xcode is up to date - Version 11.1 (11A1027)
Ive never used Quick actions before and it seamed simple but what seamed simple, just add some lines to the plist and add some code to the AppDelegate.Swift file but is taking ages to get working.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var shortcutItemToProcess: UIApplicationShortcutItem?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
shortcutItemToProcess = shortcutItem
print("Shortcut pressed")
}
return true
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {
print("Shortcut pressed")
}
func applicationDidBecomeActive(_ application: UIApplication) {
print("Shortcut pressed")
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
Thank you.