Background App Fetch and App Snapshotting - ios

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.

Related

iOS 14 app killed immediately after being minimized and receiving snapshot warning

My IOS 14 app is always being killed immediately when it is being minimized. I have already added background modes: background fetch and background processing. However, when the app goes into the background and I switch to another app, XCode is telling me this:
Snapshotting a view (0x7f91ed844000, UIKeyboardImpl) that has not been rendered at least once requires afterScreenUpdates:YES
So I thought maybe the app can't create screenshots for the app switcher and Apple then just kills the app. My problem is that the message doesn't tell me how I can add this to the view. The documentation doesn't help me either also Google and searching here doesn't help. Everything I find is about how to take a screenshot and save it somewhere which is not what I am trying to do. Does anyone have an idea how I can approach this problem?
Thank you very much!

How to take a screenshot programmatically if the app is running in background

I am writing a piece of code using swift for iOS.
It’s using location services. I need to take a screenshot of the current screen every time the location gets updated.
The thing is when the app is running in background and updating the location the screenshots taken are from my app. Not the app which is currently available in the screen.
Assume that the user plays a game in their phone. But my app run in background and updating the location when the users location is significantly changed the screenshot should be taken and it should include the game. Not my app screen.
Can some one tell me how to achieve the screenshot capability I want.
Short answer: You can't.
Apps can only take screenshots of their own content. Starting with (I think) iOS 7 Apple blocked the ability of apps to take screenshots of anything but their own content. This is for security reasons.
Imagine your app echoes each character of your password as you type it, and then replaces it with a bullet as you type the next character. Now imagine an app that runs in the background and takes a screen-shot every time your app displays a new character of the user's password.

Show several Local Notifications without creating new one

My scenario that I need to show the first Local Notification using Swift and then using the same identifier add another Local Notification, but without showing it as a popup in iOS device. So basically the flow would be like this:
Starting upload... <-- Show on the screen and adds to the Tray bar
Uploading photos... <-- Does not shows on the screen, but clears all the notifications and add another one in Tray bar silently (or changes previous one)
Uploading data... <-- Same as Uploading photos...
Finished uploading... <-- Same as Uploading photos...
Tried different ways, on Android it is not hard to do that, but iOS makes everything hard to do, is it even possible? :)
Thanks!
The reason it works on Android is because the "state showing" notifications are very Android thing. iOS is not designed for this kind of stuff because you almost never do something in the background of an app that also needs to be reflected to the user while user is outside of an app. So the real answer to your question is no. In iOS environment it is not possible to simulate Android way of showing status changes in a notification.

For iOS APP, Show custom snapshot when move APP from background to foreground

Background:
Our app will need to work like below:
Manually move APP foreground => background (Timing1)=>(Timing2)foreground
Timing1:iOS will take snapshot
Timing2:iOS will show snapshot
Automatically move APP foreground (Timing3)=>(Timing4) background =>foreground
Problem:
At Timing4 iOS show snapshot taken at Timing1 instead of Timing3.
Analyse:
I think it is because at 2 situation our App moved automatically by other APP.So iOS do not have enough time to take snapshot at timing3 after "applicationdidenterbackground" method returned.
Question:
I want to force iOS to take snapshot which will be used for timing4.
SO
How can I force iOS use the snapshot I take instead the one iOS take by itself
At which step I should input code to release the function at 1.
Thanks.

Modify iOS view while app is in background or in multitask view

I am writing an iOS app that keeps and displays the state of a system. It basically shows a light whose color represents state:
green/yellow/red light <==> OK/warning/danger
I'd prefer to show accurate state even when the app is backgrounded, and its snapshot is viewed thru the iOS multitask viewer (the view that looks like a rolodex, which you get after double-clicking the home button). I REALLY don't want to show a snapshot which displays an inaccurate state.
So my question is: can you change the view (or perhaps the app snapshot) while the app is in the background, so that when it's viewed in the multitask view it shows an accurate state.
I've seen that this is not recommended by Apple: from App Programming Guide for iOS
Avoid updating your windows and views. Because your app’s windows and views are not visible when your app is in the background, you should avoid updating them. The exception is in cases where you need to update the contents of a window prior to having a snapshot of your app taken.
However, Apple's music app does just this...if you start playing a playlist, then put the music app into the background, the cover art gets updated as the music app works thru the playlist. So this functionality must be possible somehow.
The best answer I can come up with after a bunch of searching is to alter my app's view to the splash image prior to entering background operation. This would ensure that inaccurate state isn't displayed, but also prevents showing accurate state.
You can change the snapshot view immediately before the snapshot is taken (A banking app, for example might want to obscure personal information), but you cannot continue to update the snapshot from the background once your app is suspended. You may want to adopt this approach in order to avoid displaying an inaccurate state; show nothing rather than stale data.
You might also want to consider some other options, such as a "today" widget that contains the updated status or posting local notifications when there is a significant change in status (such as entering the "red" state).

Resources