How to prevent my app from running in the background on the iPhone

Is there a way to make the application stop working instead of going into the background when you press the home button? For security reasons, it would be better if the application did not start in the background, but actually closed when you click on the house. This is not for the safety of users, but for company data in the application, so this is not the user's choice. I could not find a way to quit otherwise than to force an exit which Apple dissuades.

+3
source share
3 answers

See abandoning the background in the iphone application programming guide:

" , , , , UIApplicationExitsOnSuspend Info.plist YES.

, , .

" " , applicationWillTerminate: , ."

+8

info.plist " " "".

+2

, , , home. , UIApplicationExitsOnSuspend YES boolean plist, Simulator, Xcode Simulator .

, , . DidFinishLaunching appDelegate. - , :

if(isBackgroundProcessingSupported){
        appDelegate.bgTask = [app beginBackgroundTaskWithExpirationHandler:^{}];
        [NSURLConnection connectionWithRequest:request delegate:self];
    }

, , , , "". , , , .

. , .

, -, , .

0
source

Source: https://habr.com/ru/post/1754080/


All Articles