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:
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:
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:
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.)