13

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?

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
Houranis
  • 361
  • 2
  • 4
  • 16
  • 2
    Since iOS `10.3` this is possible! Take a look at this answer: http://stackoverflow.com/questions/41950994/is-this-possible-to-apply-the-alternative-icon-to-the-ios-application – KlimczakM Mar 30 '17 at 12:16
  • There is a solution for iOS 10.3+ https://stackoverflow.com/a/41849979/948445 – ymutlu Sep 19 '18 at 06:36

8 Answers8

16

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>
ymutlu
  • 6,585
  • 4
  • 35
  • 47
  • Try expanding on your answer. You haven't explained that it's a method on UIApplication or how to setup the plist or anything. Just saying 'call this method' isn't useful to anyone. – dlbuckley Jan 25 '17 at 15:19
  • I'd like to share this exciting news with people. I will share a how to as sson as I have done it. So sad this is not enough for you. – ymutlu Jan 25 '17 at 18:29
  • It is exciting news, you are correct. But you're answer doesn't tell the whole story about how to use this new feature, it's implications and implementation details. I down voted the answer because as it stands it's an answer simply trying to get votes and not helping anyone. If you amend your answer to fully explain the feature then I will happily up vote it :) – dlbuckley Jan 26 '17 at 09:51
11

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.

Cyrille
  • 25,014
  • 12
  • 67
  • 90
  • Would this also apply to an internal app rather than one distributed through the public App Store? Is the plist immutable? – james_fuller Feb 03 '15 at 23:25
4

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.

2

An update: since iOS 10.3 you can update the app icon by having alternate icons defined in the info.plist.

See more at Apple Docs

Okengroth
  • 83
  • 11
1

This is not possible. App icons are not dynamic and they can only be updated by submitting a new updates to your app through iTunes Connect. For more info, read the iTunes Connect Developer Guide. https://itunesconnect.apple.com/docs/iTunesConnect_DeveloperGuide.pdf

SarpErdag
  • 781
  • 1
  • 8
  • 19
0

I'm afraid not; pretty certain the app icon isn't allowed to conditionally change.

neilkimmett
  • 847
  • 9
  • 11
0

I don't think that's possible without a jailbroken phone. The app icon is contained in the application bundle, which you're not allowed to write to.

samson
  • 1,152
  • 11
  • 23
-1

I disagree with all the answer above. Please try the app "OneTap", it will allow you to make your own icon of your new app. OneTap app is free on Itune.

  • 3
    I'm sure a lot of people are interested if this is possible. Please leave a working URL link or source code of the solution. – Vincent Oct 21 '13 at 12:23
  • 1
    It is not possible! OneTap doesn't change its own AppIcon. It just open Safari with selected image and user should press save to home screen. After this you can tap on this new app icon that will open safari that will redirect you to OneTap app So change programatically app icon is not possible – AlexPrinceton May 08 '14 at 08:19