简体   繁体   中英

Update UIApplicationShortcutItem from extension

I am building a Today Extension to an app, and it works great to modify my application data. But now my dynamic UIApplicationShortcutItems are out of sync.

I can't access UIApplication.shared from my extension. Is there a way to ask the app to update UIApplication.shared.shortcutItems without bringing it to the foreground?

I have found that MMWormhole is a good solution to this problem. It acts somewhat like an NSNotificationCenter notification between the app extension and its host application. This lets you notify the app to update its shortcut items whenever the today widget takes some action that makes the shortcuts get out of sync. The only downside is that the host application must be actively running in the background for the notification to trigger its intended action.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM