SwiftUI

iOS14 Widget小组件开发实践6——关于组件数据刷新间隔问题

发现很多人对Widget的数据刷新有疑问,发现有时候会根据设置的时间间隔进行刷新,有时候又差距很明显,特别是上线的应用在刷新问题上大概率不遵守代码设置。翻了下苹果官方对这个问题的说明,在问题里面看到了苹果技术人员对开发者提问的回答:

https://developer.apple.com/forums/thread/653265?answerId=619739022#619739022
Updating every minute is far too aggressive. Widgets have a limited number of updates and if you were to try to update every minute, you’ll quickly run out of updates. While debugging with Xcode these limits are not imposed, but if you’re running your app outside of Xcode you’d see the behavior you’re describing where your widget would stop updating.
What happens if you update every 15 minutes? If that doesn’t work, please file a Feedback Assistant report with the details of what you’re doing and the results you see.

根据有道翻译大意如下:

每分钟都更新太激进了。小部件的更新数量是有限的,如果你试图每分钟更新一次,你很快就会用完更新。在使用Xcode进行调试时,这些限制不会被施加,但如果你在Xcode之外运行你的应用程序,你会看到你描述的小部件停止更新的行为。
如果你每15分钟更新一次会发生什么?如果这不起作用,请提交一个反馈助理报告,详细说明你正在做什么和你看到的结果。