I'm looking after some Obj-C sample code for a dynamic UIApplicationShortCutItem
.
Basically, I have three static UIApplicationShortcutItems
and I only want to display them under certain conditions. I presume that you can't change the visible status of a static UIApplicationShortcutItem
, so I'm looking after a simple way to add dynamic UIApplicationShortcutItem
s.
For someone who is looking for a Swift4 version for @chengpei answer, it is here:
I've post a simple objective-c example on GitHub that add/remove shortcuts to Home Screen.
You can check it here: https://github.com/cjimenezpacho/3Dtouch-home-screen-quick-actions
I have a method on App Delegate that handles shortcut items (based on another stackoverflow answer that I can't found :( ):
It is called by application:didFinishLaunchingWithOptions and application: performActionForShortcutItem whether app is launched or not.
And to add/remove shortcuts on demand:
Hope it helps and feedback are welcome!
Here's how to detect if the app was launched with a quick shortcut in Objective-c.
To detect the type of shortcut selected while the app is running in the background.
You can use the following code to add shortcutitem for you app dynamic: