问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/41207955/update-uiapplicationshortcutitem-from-extension