Setting Alternate App Icons in iOS 10.3 Without Showing an Alert

UPDATE: To be clear, there is a very good chance submitting an app using this method could get you rejected in App Review. Use at your own risk. Also, this method is super buggy. Don’t say I didn’t warn you.


iOS 10.3 added a cool new API for changing your app’s icon. The API is limited in several ways, one of the biggest being that changing the app icon with the API causes the system to automatically display an alert informing the user of the change:

Hey look, a free sneak peak at the app I'm working on.

This is fine. There’s really nothing wrong with this. But I noticed that couple of applications – such as Bear and Scanbot have managed to change their app icon without showing that alert.

So I knew it was possible.

The system dialog is obviously a variant of a UIAlertViewController, based on it’s appearance and behavior, so I first thought there might be some method of calling .dismiss(animated:completion:) on it; alas, there was not.

I then had another idea: what if, immediately upon calling setAlternateIconName(_:completionHandler:), I created and presented a different view controller? Would that interrupt the alert showing? And if so, could I dismiss that temporary view controller quickly enough that the user would never notice?

As it turns out: yep. That’s exactly what I was able to do, with this code:

if UIApplication.shared.supportsAlternateIcons {
    UIApplication.shared.setAlternateIconName("nameOfAlternateIcon")
    
    let tempViewController = UIViewController()
    
    self.present(tempViewController, animated: false, completion: {
        tempViewController.dismiss(animated: false, completion: nil)
    })
    
}

By presenting a temporary ViewController – without animation – and then instantly dismissing that ViewController within the completion block of the present, you end up with this effect:

Much better.

Hopefully iOS 11 will bring some maturity to this API - I’d love if this sort of workaround wasn’t needed. Personally, I think the user should be able to allow icon changes without confirmation, including updates in the background. (I’d also like to have the ability to generate these images in code, rather than supplying image files, but that opens the door for abuse.)