Skip to content

ccavazos/titanium-alternate-icons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alternate App Icon Ti Module (iOS 10.3+)

Summary

Leverage the ability to change the app icon in iOS 10.3+.

WhiteIcon

Requirements

  • Titanium Mobile SDK 6.0.3.GA or later
  • iOS 10.3 or later
  • Xcode 8.3 or later

Download

Setup

Unzip the module in the modules/iphone/ folder of your project. Add the module requirement in your tiapp.xml file.

<modules>
    <module platform="iphone">ti.alternateicons</module>
</modules>

In order to use this module with Titanium you will need to disable app thinning by editing the adding the following property in your tiapp.xml:

<ios>
    <use-app-thinning>false</use-app-thinning>
</ios>

Alternatively, you can pass the hashed name of the icon to the methods. You can look up the generated names in build/iphone/Assets.xcassets.

Next, you have to declare the icons that you will use in your by adding the following to the tiapp.xml. The <key> named alloyIcon is the string that you will use to call the set​Alternate​Icon​Name method .

<ios>
    <dict>
        <key>CFBundleIcons</key>
        <dict>
            <key>CFBundleAlternateIcons</key>
            <dict>
                <key>alloyIcon</key>
                <dict>
                    <key>CFBundleIconFiles</key>
                    <array>
                        <string>alloy</string>
                    </array>
                </dict>
            </dict>
            <key>CFBundlePrimaryIcon</key>
            <dict>
                <key>CFBundleIconFiles</key>
                <array>
                    <string>AppIcon</string>
                </array>
            </dict>
        </dict>
    </dict>
</ios>

Copy your icons into the app/assets/ folder. You can try it out with alloy@2x.png and alloy@3x.png in the example folder of this repo.

Hyperloop

This module is also built in Hyperloop to demonstrate the native API access with JavaScript. You can simple require the ti.alternateicons.js in your application and run it!

Example

var AlternateIcons = require('ti.alternateicons');

if (AlternateIcons.isSupported()) {
    AlternateIcons.setAlternateIconName('alloyIcon', function(e) {
        if (!e.success) {
            Ti.API.error(e.error);
        }
    });
}

Methods

  • isSupported
  • supportsAlternateIcons
  • alternateIconName
  • set​Alternate​Icon​Name
  • setDefaultIconName

Author

Cesar Cavazos (@cesarcvz / Web)

License

Apache 2.0

Contributing

Code contributions are greatly appreciated, please submit a new pull request

Special Thanks

To Hans Knoechel because this module was created using titanium-review-dialog as a reference.