3

Since iOS 10.3 has been released, Apple added a new feature which allows us to change the app icon dynamically, by using setAlternateIconName(_:completionHandler:) method. So far, as mentioned in the method documentation, we have to mention the name(s) of the alternate app icon(s) in the project .plist file, assigned to CFBundlePrimaryIcon key.

Actually, when working with static icons (icons that have been added directly to the app main bundle) it works as expected without any problems:

enter image description here

My question is:

Is it possible -or is there a workaround- to set the alternate app icon dynamically (for instance: icons that have been downloaded from the web and saved in the app documents directory)?

Ahmad F
  • 30,560
  • 17
  • 97
  • 143

1 Answers1

3

I don't think its possible.

setAlternateIconName(_:completionHandler:) API looks for the icons inside app bundle and cannot be changed to fetch from sandbox.

Also, most probably Apple reviews the app icons you have bundled for avoiding use of same app icons or icons similar to Apple apps.

Refer: https://www.hackingwithswift.com/example-code/uikit/how-to-change-your-app-icon-dynamically-with-setalternateiconname

Puneet Sharma
  • 9,369
  • 1
  • 27
  • 33
  • 1
    Thank you for the answer. "setAlternateIconName(_:completionHandler:) API looks for the icons inside app bundle and cannot be changed to fetch from sandbox", could you please add a reference for it? – Ahmad F Sep 10 '17 at 12:43
  • @AhmadF: I have included a link to a blog from hackingswift. I am looking inside Apple doc as well. I will include that in my answer as well. I am pretty sure it cant be done though. – Puneet Sharma Sep 10 '17 at 12:45
  • I was thinking about it, even as a workaround it might won't work... at some point, you have to mention the icon names in the project plist, which probably couldn't be done at runtime. I would be great if you could find a reference from apple that mentioning this... – Ahmad F Sep 10 '17 at 12:49
  • @AhmadF: Even if you can provide the names at the runtime, you would need to bundle the icons with the app. I hope apple revisits this in future but currently its not possible. – Puneet Sharma Sep 10 '17 at 12:51
  • If you would add a reference for something official, I will be glad to accept it :) – Ahmad F Sep 12 '17 at 06:07
  • @AhmadF, i'v been looking for a workaround on this as well, what i have in my mind, make the file icon file names static like (icon1, icon2) , and override the icon on runtime, or remove the previous one and set new one, but since all i could do was download into the documentDirectory, it's been a failure : ) do you have a solution or workaround for it now ? – judge May 14 '18 at 17:03