Currently I am trying to find a work around to fetch data from server and update user defaults when app is forced quit. Can anyone suggest for this ?
Background fetch when app is forced quit
First, you may want to read about iOS Background Execution Limits
Force quit is considered a drastic choice by the user to say that they do not want the app to run, often because it misbehaved in some unrecoverable manner. My suggestion would be to respect that choice and not to find ways around it.
If you have to, you can use a Notification Service Extension as discussed at https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension.
The Notification Service Extension will be executed for every visible push notification. So, it could serve your needs, as long as the user has not disabled the visibility of your notifications through various settings.
The service extension will not be executed for push notifications that will not be presented visually. This way, you are able to execute code in an extension and the user will be aware that this is happening.
My thoughts:
In my view, Apple may want to reconsider how it interprets users force-quitting apps. Closing an app from the App Switcher isn’t necessarily a sign that the user dislikes it or finds it unhelpful. Many users simply prefer to keep the switcher uncluttered. A force-quit app can still serve an important purpose, and because Apple has not clearly communicated how background behavior works after a manual terminate, many apps are unintentionally penalized by this misunderstanding. Users already have better tools for signaling preference, such as disabling notifications. Ultimately, deleting an app is the only meaningful indication that a user truly does not want it. Just my two cents.
Apple may want to reconsider how it interprets users force-quitting apps.
If you want to get your “two cents” in front of the folks who have the power to enact change, I suggest you put them in an enhancement request.
One of the reasons why these behaviours are not documented is that Apple reserves the right to change them. This has happened in the past, and it’s not hard to imagine it happening again in the future.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Thank you @DTS Engineer !