0

I am new to IOS development I want to remove my application from recent apps which is developed in Objective C. I tried UIApplicationExitsOnSuspend in

info.plist

, but no luck still application is showing in info.plist. Can anyone help me on this. Thanks in Advance !!!

Pinki
  • 21,723
  • 16
  • 55
  • 88
  • excuse me... _what_ are you trying to do by _what_? – holex Nov 04 '19 at 09:47
  • to remove app from recent apps . I tried UIApplicationExitsOnSuspend true in info.plist – Pinki Nov 04 '19 at 10:31
  • You can't. Even if `UIApplicationExitsOnSuspend` was still supported, the snapshot of your app would still appear in the app switcher, your app just wouldn't be in the suspended state. Perhaps you could explain *why* you want to remove the app from the app switcher and we could suggest an alternative approach. – Paulw11 Nov 04 '19 at 10:36
  • I have received this issue from my security team "Backgrounding Screenshots Enabled By default, when an iOS application is sent to the background (e.g. by pressing the Home button), the operating system will take a screenshot of the current UI and store it for future . application did not disable this feature, and hence screenshots containing email addresses and mobile phone numbers could be written to the device file system." – Pinki Nov 04 '19 at 10:41

2 Answers2

1

You could use concept of the cover window.
When app will resign active state you show your cover, and system will take snapshot of that cover instead of last visible UIViewController. When app will become active you hide and deallocate your cover window. Here is example

#import "AppDelegate.h"

@interface AppDelegate ()

@property (nonatomic) UIWindow *coverWindow;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    self.coverWindow = UIWindow.new;
    self.coverWindow.rootViewController = UIViewController.new;
    [self.coverWindow makeKeyAndVisible];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [self.coverWindow removeFromSuperview];
    self.coverWindow = nil;
}

@end
Mark
  • 701
  • 6
  • 12
0

UIApplicationExitsOnSuspend is deprecated. You shouldn't use it any more. There has been reports of apple rejecting apps with that key. As per apple:

Deprecated

The system now automatically suspends apps leaving the foreground when they don’t require background execution. For more information, see About the Background Execution Sequence.

So for now, you are stuck with letting apple handle the background state of apps. Forcefully trying to exit the app by any manner would lead to a rejection from App Store.

UPDATE

I just noticed your comment saying what you actually want. To prevent the Background Snapshot, you can add a custom view to the window. This is similar to the answer posted by Mark Agranal below, but the thing is you don't need to add a new Window or new ViewController. You can simply add a custom view to the window and remove the view when the app reenters active state. In your AppDelegate:

// The view to use as a mask
@property (nonatomic, weak) UIView* coverView;

// Add the view to window
-(void)applicationWillResignActive:(UIApplication *)application
{
    coverView = [[UIView alloc]initWithFrame:[self.window frame]];
    [self.window addSubview:coverView];
}

// Remove the view to window
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    if(coverView != nil) {
        [coverView removeFromSuperview];
        coverView = nil;
    }
}

Note that you can add any view to the window using the above method. The system will take screenshot of the added view and hence the sensitive user data will be protected.

Harikrishnan
  • 7,765
  • 13
  • 62
  • 113
  • then how we can achieve this concept – Pinki Nov 04 '19 at 10:33
  • There is no achieving that concept as of now. Apple is strict with its policies(at least with third party developers). That is the major difference when you come from Android to iOS. Your hands are basically tied at so many different places. Everything you do in Android cannot be done in iOS. :) – Harikrishnan Nov 04 '19 at 11:14
  • @Pinki please see the updated answer. – Harikrishnan Nov 04 '19 at 11:29