Update UIApplicationShortcutItem from extension

送分小仙女□ 提交于 2019-12-11 00:15:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!