Hedge
Hedge

Reputation: 16748

How to close iOS app completely (wipe the RAM it uses) when switching to another app/homescreen

I have a React Native app. When its not in the foreground it needs to be closed completely. The content of its memory must be gone and I would also like to wipe the cache.

Is this possible at all and if yes, how?

Upvotes: 0

Views: 289

Answers (1)

Paulw11
Paulw11

Reputation: 114875

If you set the info.plist key UIApplicationExitsOnSuspend to true then your app will be terminated when the user presses the home key rather than moving to the background.

UIApplicationExitsOnSuspend (Boolean - iOS) Specifies that the app should be terminated rather than moved to the background when it is quit. Apps linked against iOS SDK 4.0 or later can include this key and set its value to YES to prevent being automatically opted-in to background execution and app suspension. When the value of this key is YES, the app is terminated and purged from memory instead of moved to the background. If this key is not present, or is set to NO, the app moves to the background as usual.

Any cache files that your app has created "on disk" will need to be deleted by your app in applicationWillTerminate. Note that this method may not be called if the user terminates the app or the battery goes flat, so it is probably best to avoid persisting any sensitive data to disk.

Upvotes: 1

Related Questions