Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this possible to apply the alternative icon to the iOS application?

I need to change the app icon based on region, is this possible?

like image 340
Mohamed Raffi Avatar asked Jan 31 '17 06:01

Mohamed Raffi


People also ask

Can you change app icon iOS?

Tap the placeholder app icon. From the drop-down menu, select Take Photo, Choose Photo, or Choose File, depending on where your replacement app icon image is located. Select your replacement image. In the text field, rename the app as you want it to appear on the home screen.

What app can i use to change the icon of an app?

The easiest way to decorate your android. Icon Changer is the application that makes shortcut with a new icon at home screen. Icon can be chosen from gallery and lots of icon packs.


2 Answers

Yes, this is possible since iOS 10.3.

First, you need to define all alternative icons in your Info.plist file, you can't fetch them dynamically.

In the example below we define 2 alternative icons: "de" and "fr":

<key>CFBundleIcons</key>
 <dict>
  <key>CFBundleAlternateIcons</key>
  <dict>
   <key>de</key>
   <dict>
    <key>CFBundleIconFiles</key>
    <array>
     <string>ic_de</string>
    </array>
    <key>UIPrerenderedIcon</key>
    <false/>
   </dict>
   <key>fr</key>
   <dict>
    <key>CFBundleIconFiles</key>
    <array>
     <string>ic_fr</string>
    </array>
    <key>UIPrerenderedIcon</key>
    <false/>
   </dict>
  </dict>
  <key>CFBundlePrimaryIcon</key>
  <dict>
   <key>CFBundleIconFiles</key>
   <array>
    <string>ic_none</string>
   </array>
  </dict>
 </dict>

Then you can set the icon name based on anything you like (game progress, weather conditions, premium user, etc.). To change the icon use:

UIApplication.shared.setAlternateIconName("de") { (error) in
    if let error = error {
        print("err: \(error)")
        // icon probably wasn't defined in plist file, handle the error
    }
}

Result:

Gif showing the icon changing in response to a segmented control

The gif is from a Medium article by Julien Quéré.

like image 159
KlimczakM Avatar answered Nov 06 '22 07:11

KlimczakM


This feature available in 10.3 (Beta)

Discussion Use this method to change your app's icon to its primary icon or to one of its alternate icons. You can change the icon only if the value of the supportsAlternateIcons property is true.

You must declare your app's primary and alternate icons using the CFBundleIcons key of your app's Info.plist file. For information about how to configure alternate icons for your app, see the description of the CFBundleIcons key in Information Property List Key Reference.

Take a look at:

apple documentation

like image 35
Andriy Savran Avatar answered Nov 06 '22 08:11

Andriy Savran