0

I'm trying to set an alternative icon for my app but from some reason fail to do so. [UIApplication sharedApplication].alternateIconName keeps returning nil, although the plist structure looks correct:

<key>CFBundleIcons</key>
<dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
        <key>AlternateIcon</key>
        <dict>
            <key>CFBundleIconFiles</key>
            <array>
                <string>AlternateIcon</string>
            </array>
            <key>UIPrerenderedIcon</key>
            <false/>
        </dict>
    </dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
        <key>CFBundleIconFiles</key>
        <array>
            <string></string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
    </dict>
</dict>

The code:

NSLog(@"Icon = %@",[[UIApplication sharedApplication] alternateIconName]);

prints:

Icon = (null)

gerbil
  • 859
  • 7
  • 26
  • Possible duplicate of [Is this possible to apply the alternative icon to the iOS application?](https://stackoverflow.com/questions/41950994/is-this-possible-to-apply-the-alternative-icon-to-the-ios-application) – MwcsMac Jan 22 '18 at 15:29
  • This seemingly follows the same guideline and still doesn't work, so it doesn't solve my problem. – gerbil Jan 22 '18 at 15:36
  • Make sure your images are saved correction as png's. If the image doesn't display in the alert view that popups up it will not set to the new icon. – MwcsMac Jan 22 '18 at 16:09
  • The image size is 120x120 and named `AlternateIcon@2x.png` and is in the project (not xcassets) – gerbil Jan 22 '18 at 17:30
  • Try removing `UIPrerenderedIcon ` as that is not needed. Also make sure to check your project for any errors. If your project has Red errors related to images the project will still build but you may not get the results you expect. – MwcsMac Jan 22 '18 at 19:20
  • Tried. No change :-/ No red errors. – gerbil Jan 24 '18 at 10:32
  • Take a look at this [code](https://github.com/mwcs01/set-alternate-icon) to see if there is something you missed. Or post your code on how you are switching the icons. – MwcsMac Jan 24 '18 at 17:55
  • Thanks, I don't have any code other than `[UIApplication sharedApplication].alternateIconName` which returns `nil`. This makes any other code redundant.. – gerbil Jan 24 '18 at 21:32
  • Update your question with the code that you have setup in your application related to `UIApplication.shared.setAlternateIconName`. – MwcsMac Jan 24 '18 at 21:59
  • Edited. See update. – gerbil Jan 25 '18 at 09:36
  • That code is working correctly. You need to set the icon. – MwcsMac Jan 25 '18 at 14:45
  • You are right. I'll make that clear in the answer. – gerbil Feb 06 '18 at 17:23

1 Answers1

0

[[UIApplication sharedApplication] alternateIconName] returns nil UNLESS an alternative icon has been set.

gerbil
  • 859
  • 7
  • 26