2

I want to download the app launcher icon through an API and replace the existing icon with this new one, for both Android and IOS applications. I am using ionic-3 Cordova for development.

Is this possible?

2 Answers2

1

It's not possible. The icons are static and cannot be changed in iOS. It's not Android.

Alexander Volkov
  • 7,904
  • 1
  • 47
  • 44
1

Since iOS 10.3+ it is possible (since 2017), but for Cordova applications (like Ionic) is that it will depend on a specific plugin.

You can try this plugin (only iOS, not Android) cordova-plugin-app-icon-changer

Install using:

cordova plugin add cordova-plugin-app-icon-changer

For check support:

AppIconChanger.isSupported(function(supported) {
    if (supported) {
          ...
    } else {
          ...
    }
});

For change icon:

AppIconChanger.changeIcon({
    iconName: "<icon name here>",
    suppressUserNotification: true
}, function() {
     // Changed...
}, function(err) {
     // If failed ...
});

For more plugins see: https://cordova.apache.org/plugins/?q=icon

Note: if something is desired you could implement your own plugin (or if you want to create a native application) using setAlternateIconName(_:completionHandler:)

It is important to check if the exchange is supported using supportsAlternateIcons

After placing the images in the "assets" go to Info.plist (CFBundleIcons) add CFBundleAlternateIcons with the items corresponding to the images, as in the example:

▼ CFBundleIcons
  ▼ CFBundleAlternateIcons
    ▼ <icon name here>
      ▶ CFBundleIconFiles

If you need support for iPad the structure should look something like:

▼ CFBundleIcons
  ▼ CFBundleAlternateIcons
    ▼ <icon name here>
      ▶ CFBundleIconFiles
▼ CFBundleIcons~ipad
  ▼ CFBundleAlternateIcons
    ▼ <icon name here>
      ▶ CFBundleIconFiles

Example in image for Cordova projects (eg. Ionic)

info.plist


Android cordova plugins

So far I haven't found existing plugins that do this for Android, but according to this answer How to change an application icon programmatically in Android? (I couldn't test the answers at the moment) it is apparently possible to change the icon.

Protomen
  • 9,471
  • 9
  • 57
  • 124