0

I am trying to "prevent the app from using the recent snapshot image during the next launch cycle" using the ignoreSnapshotOnNextApplicationLaunch() method documented at https://developer.apple.com/documentation/uikit/uiapplication/1623097-ignoresnapshotonnextapplicationl

Apple very specifically says "You must call this method from within the code you use to preserve your app’s state."

I am calling this method from every single possible Saving and Restoration method without success. Including encodeRestorableStateWithCoder() as mentioned in App screen snapshot being shown instead of launchScreen during state restoration

Any help?

castillejoale
  • 519
  • 4
  • 13

1 Answers1

0

I've tried to call ignoreSnapshotOnNextApplicationLaunch in every possible methods and it still seems broken to me.

Instead, I ended up using a fake launch image to prevent user from seeing the real App content:

- (void)applicationWillResignActive:(UIApplication *)application {
  // This line doesn't seem to work...
  // [application ignoreSnapshotOnNextApplicationLaunch];

  self.appCover = [[UIImageView alloc] initWithFrame:[self.window frame]];
  // setup a little in order to make our fake looks better
  self.appCover.contentMode = UIViewContentModeScaleAspectFit;
  self.appCover.backgroundColor = [UIColor whiteColor];
  // This is the image we use in our LaunchScreen.xib
  [self.appCover setImage:[UIImage imageNamed:@"LaunchImage"]];
  [self.window addSubview:self.appCover];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  // get rid of the fake launch image after App become active
  if (self.appCover) {
    [self.appCover removeFromSuperview];
    self.appCover = nil;
  }
}

Not perfect but works like what ignoreSnapshotOnNextApplicationLaunch should do.


2019-04-11 UPDATE:

This is pretty embarrassing: turns out my app crashes every time after -[UIApplication terminateWithSuccess] due to some third party frameworks not being released properly.

So in my case, I just need to release these frameworks correctly in applicationWillTerminate, and everything works as expected. (don't even need the ignoreSnapshotOnNextApplicationLaunch approach)

David Lee
  • 74
  • 8