When will getPlaceholderTemplateForComplication() method be called? - ios

I'm trying to build a simple complication template for a WatchOS app, but I'm stuck trying to understand when will the ComplicationController class's method getPlaceholderTemplateForComplication() be called.
Apple's documentation says
When your app is first launched, ClockKit calls this method,
but if i run the simulator, it most often won't fire.
Turning the "Show App on Apple Watch" switch off and back on doesn't help.
When will getPlaceholderTemplateForComplication() method be called?

The placeholder template is called when you are customizing the watch face and selecting which complication will be shown. The system calls getPlaceholderTemplateForComplication() once, then caches the result. It won't keep calling the method every time you customize the complication.
As you scroll through the complication choices, the static details shown there are the details returned for the placeholder template.
Once your complication is active -- shown on the watch face -- the placeholder template does not get called. Instead the timeline entries come from these complication dataSource methods:
getCurrentTimelineEntryForComplication, and optionally from
getTimelineEntriesForComplication if time travel is supported.
Installing or removing a watch app has nothing to do with the placeholder template.
For watchOS 3:
watchOS 3 supports a face gallery which can let the user see and customize watch faces and complications. The static complication data shown in the gallery also comes from the placeholder template.

Related

SKStoreReviewController requestReview does not work in iMessage extension

I tried calling SKStoreReviewController.requestReview() in my iMessage extension, but it never shows the UI. I know the system controls whether or not this appears, but based on the documentation (https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview) it seems like it should appear at least once.
If I move the call to the containing app, it works as expected. The entire user experience is based out of the imessage extension, so this is not really a viable solution

Background App Fetch and App Snapshotting

I am developing an app where I use iOS's "background app fetch" to keep the data of my app up to date. This is working fine except the "snapshot" of the app is not updated with this fetch.
When I say "snapshot" I mean the image that iOS takes when it goes into the background. This is the image that is displayed for the second before your app loads. At the moment this means users (particularly those on older phones) may see old information for a second or so then have it replaced with new information.
Does anybody know more about when the app takes the snapshot and if this can be forced (for example when I fetch new data in the background).
Alternatively can anybody think of a way I can achieve this effect?
Check out the documentations on Managing the State Restoration Behavior. It's not possible to update the snapshot once you loaded new data from the background. What you can do is to just tell the UIApplication to not show the snapshot but the default launch image using -ignoreSnapshotOnNextApplicationLaunch.
In my opinion however, this shouldn't be necessary. I can image that Apple will improve this with iOS 9.
How about resetting your app to a "neutral" state when it is about to enter the background? Displaying an empty table, for example.
You won't have the latest data, but you won't have wrong data either.

Apple watch app entry point

In xcode you need to specify the initial interface controller for the watch app, which is the entry point of the watch app, shown first when you open it.
But is it shown every time you open the watch app? For example you open a watch app, navigate to a page, close it, and open it again. Does it open on the page you were last time (like on iOS), or again on the first interface controller?
According to apple documentation:
Normally, WatchKit displays the first interface controller in the sequence initially.
Well, normally is not every time. I looked through watch app videos from the watch presentation event, but there wasn't a case when they opened an app twice.
That's a great question!
Main Entry Point
First off, you can certainly avoid showing that MainInterfaceController each time. See this thread for more information where I detail exactly how to use that entry point to launch the appropriate set of InterfaceController objects.
Watch Extension Lifecycle
It is VERY important to understand what the expected lifecycle of a Watch Extension actually is. It will only run while the user has the Watch up and is running your app. This will generally be 1-5 seconds (opinionated value). As soon as the user lowers their wrist, your Watch Extension will be terminated completely. Therefore, it is going to be restarted every time at the same entry point. This means that you need to track your app state if you want to launch a different page set in the MainInterfaceController.
Hopefully that helps shed some light.
If your WatchKit extension is still running, it will pick up where you left off. If not, and everything has been dumped out of memory, it should start again with your initial interface controller.

Reset View hierarchy iOS

I'd like to add some code to the app delegate that resets the view hierarchy back to the beginning.
My app is basically a demonstration mockup, and I'd like EVERYTIME the app opens that it resets to the first view in the storyboard, and doesn't remember what page the user was on when they closed or 'minimized' the app.
I'm using iOS sdk 8.1, and Xcode 6.
Putting aside that it's actually quite bad user experience - it's very easy to do. You just need to specify that your app doesn't run in the background, and each time user closes app, next time - brand new copy will be launched.
Here is what you need to set in your project properties in Xcode:
If your'r info.plist Show raw keys/values option are enabled, the property is named UIApplicationExitsOnSuspend which you can get by right clicking on the empty space of info.plist properties table and selecting Add Row option as follows
and right after that you will be presented with following option,
where you can select second options which is Application does not run in the background.
Selecting the mentioned property and setting it to YES, the app opt out of background mode and it cycles between the not-running, inactive, and active states and never enters the background or suspended states and moved back to the not-running state. In other words, iOS will not preserved any states which allows the app to run as fresh on next launch.

App update data from web periodically

I'm building an iPhone app where most of the content is dynamically loaded from my web server. The content is updated once per day. Here's the issue I ran into when testing my app on my device. I noticed that I would just close the app, and the next day I didn't see the new content. I had to go close the app fully (via multitasking) and then go back into it to update the content.
I could use this in the app delegate:
- (void)applicationWillEnterForeground:(UIApplication *)application
but, I load all the content in each View Controller... how should I go about re-loading my data?
Also...
If I update the array of objects that the data is pulled from in the UITableView, will the UITableView update automatically?
Thanks for any help!!
Note the documentation for that method also says, "The application also posts a UIApplicationWillEnterForegroundNotification notification shortly before calling this method to give interested objects a chance to respond to the transition."
Your view controller could be considered an interested object.
Table views can be told to reloadData.

Resources