Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change app icon programmatically

Tags:

ios

icons

I have two app icons built-in (free and premium), is it possible to replace free icon to premium icon programmatically after in-app purchase is completed successfully?

like image 591
Houranis Avatar asked Apr 06 '12 10:04

Houranis


People also ask

How do I change programmatically launcher icon?

Make a method that will be used to disable 1st activity-alias that contains default icon & enable 2nd alias that contains icon need to be changed. // Switch app icon to new icon GeneralUtils. changeAppIconDynamically(EditProfileActivity. this, true); // Switch app icon to default icon GeneralUtils.

Can I change app icon dynamically in Android?

In this article, we are going to learn how to change the App Icon of an App on the Button Click. This feature can be used when we have an app for different types of users. Then as per the user type, we can change the App Icon Dynamically.

Can app icons be changed?

Press and hold the app icon until a popup appears. Select “Edit”. The following popup window shows you the app icon as well as the application's name (which you can also change here). To choose a different icon, tap on the app icon.

How do you permanently change app icons?

To change individual Android app icons in Nova, as an example, long-press any app's icon on your home screen (to change a shortcut) or in the app drawer (to change the main app icon) and choose Edit. In the resulting menu, tap the current app icon to choose another.


3 Answers

There is a new solution for this situation.

You can use

setAlternateIconName(_:completionHandler:)

iOS 10.3 is out with xcode 8.3.

10.3+

Update:

Usage is pretty simple, the key is to find out plist usage and note that you can not load assets from xcassets ( at least didnt work for me ). You need to add your icon files to project and prefer 180x180 images for quality.

You need to use "Icon files (iOS 5)", new Icon files does not work.

One last thing, when you change icon on a button click it will popup a Alert window that says 'You have changed the icon for "IcoTest".'

enter image description here

//ViewController.swift
@IBAction func ico1Click(_ sender: Any) {
    if UIApplication.shared.supportsAlternateIcons{
        UIApplication.shared.setAlternateIconName("Icon2", completionHandler: { (error) in
            print(error ?? "")
        })
    }else{
        print("NO NO")
    }
}

//Info.plist
<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>Icon1</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater1_180x180</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
        <key>Icon2</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>alternater2_180x180</string>
            </array>
        </dict>
    </dict>
</dict>
like image 150
ymutlu Avatar answered Oct 21 '22 08:10

ymutlu


No, the icon is specified in the application bundle, which you must not change. If you change it, your app signature will become invalid (not the same checksum) and thus your app won't run anymore.

like image 38
Cyrille Avatar answered Oct 21 '22 08:10

Cyrille


No, definitely not. That part of the application bundle is read-only, and also code signed.

The answer regarding the TapOne app is something completely different. It creates "web clips" to web sites or phone numbers. For example, to create an iPhone icon for your website, you would add something like this to your web page header:

<link rel="apple-touch-icon" href="/your-custom-icon.png"/>

There is more info available here: https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

TapOne and web clips do not programmatically change the icon within an application bundle.

like image 22
Cole Joplin Avatar answered Oct 21 '22 08:10

Cole Joplin