15

iOS 10.3 comes with dynamic app icon changing feature. Developers will now be able to change app icons without an app update.

I want to change my app icon dynamically, how can i change my app icon programmatically.

Thanks in advance.

Krunal
  • 77,632
  • 48
  • 245
  • 261
Gison George
  • 379
  • 1
  • 3
  • 15
  • 2
    https://developer.apple.com/reference/uikit/uiapplication/2806818-setalternateiconname ? – Larme Apr 05 '17 at 14:23
  • Duplicate of: https://stackoverflow.com/questions/41950994/is-this-possible-to-apply-the-alternative-icon-to-the-ios-application – KlimczakM Mar 15 '19 at 09:32
  • https://www.hackingwithswift.com/example-code/uikit/how-to-change-your-app-icon-dynamically-with-setalternateiconname – RY_ Zheng Apr 06 '20 at 10:07

1 Answers1

19

Yes, iOS 10.3 finally gives developers the ability to change their app’s icon programmatically.

It is possible to change appIcon from iOS 10.3. For that you need to set supportsAlternateIcon to Yes in info.plist.

Both primary and secondary icons should be added in CFBundleIcons key of your app's Info.plist file.

//Info.plist
<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>Icon1</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater1</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>Icon2</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater2</string>
            </array>
        </dict>
    </dict>
</dict>

To change App Icon following UIApplication method needs to be called:

Objective C:

[[UIApplication sharedApplication] setAlternateIconName:@"alternater2" completionHandler:^(NSError * _Nullable error) {
        NSLog(@"Error...");
}];

Swift 3:

if UIApplication.shared.supportsAlternateIcons{
        UIApplication.shared.setAlternateIconName("alternater2", completionHandler: { (error) in
            print(error ?? "")
        })
}

For more detailed tutorial, See:
Apple Document: setAlternateIconName(_:completionHandler:)
How to change your app icon dynamically with setAlternateIconName()

Krunal
  • 77,632
  • 48
  • 245
  • 261