从扩展名更新UIApplicationShortcutItem [英] Update UIApplicationShortcutItem from extension

查看:164
本文介绍了从扩展名更新UIApplicationShortcutItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为应用构建今日扩展",它可以很好地修改我的应用数据.但是现在我的动态UIApplicationShortcutItems不同步了.

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.

我无法从我的分机访问UIApplication.shared.有没有办法要求应用程序更新UIApplication.shared.shortcutItems而不会使其前台出现?

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?

推荐答案

我发现 MMWormhole 是解决这个问题的好方法.它的作用有点像应用程序扩展与其宿主应用程序之间的NSNotificationCenter通知.这使您可以在Today小部件采取某些使快捷方式不同步的操作时通知应用程序更新其快捷方式项.唯一的缺点是主机应用程序必须在后台主动运行,通知才能触发其预期的操作.

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.

这篇关于从扩展名更新UIApplicationShortcutItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆