Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 Today View Widget: How to tell if it's *actually* on screen / visible?

I have a widget which retrieves updates from a server at regular intervals throughout the day, but want it to immediately update again if the user actually looks at it. This always worked fine in iOS 8/9... viewWillAppear fired specifically when, well, the view was about to appear.

But in iOS 10, it seems to happen at other times as well. Not sure when. But suddenly I'm getting about 5x as many hits on the update service, which is a paid service, so this is a real problem.

Is there a way, on a Today widget, to be guaranteed that the widget is actually visible? Or, at the very least, that the Today View is actually visible?

like image 784
DanM Avatar asked Oct 22 '16 13:10

DanM


People also ask

What is the Today widget on iPhone?

Widgets show you current information from your favorite apps at a glance—today's headlines, weather, calendar events, battery levels, and more. You can view widgets in Today View. You can also add widgets to your Home Screen to keep this information at your fingertips.

What is today view and search?

"Today View" is where the iPhone houses widgets. Turn on your iPhone, and swipe right from the lock screen (or the first page of your home screen). The Today View gives you a quick glimpse at your day, but you can tailor it to house your shortcuts.


1 Answers

I'd bet that the 5x as many hits is because of how users unlock their devices on iOS 10 now. Swiping from the lock screen shows the users widgets instead of unlocking their device. If you're requesting in your viewWillAppear then every time a users muscle memory tries to unlock the device the old way, by swiping, your widget is sending a server request. You might want to setup a timer for the request, or add a refresh button.

like image 96
Daniel Storm Avatar answered Nov 16 '22 02:11

Daniel Storm