GithubHelp home page GithubHelp logo

zagham-nadeem / app-icon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from capacitor-community/app-icon

0.0 0.0 0.0 12.69 MB

Capacitor plugin for managing an app's icon. The main feature being that you can programmatically change the app icon.

License: MIT License

JavaScript 2.32% Ruby 8.29% Objective-C 4.62% TypeScript 25.78% CSS 5.96% Swift 38.85% HTML 14.18%

app-icon's Introduction


App Icon

@capacitor-community/app-icon

Capacitor community plugin for managing an app's icon. The main feature being that you can programmatically change the app icon.


Maintainers

Maintainer GitHub Social
John Borges johnborges @johnborges

Before Starting

This plugin only changes the main app icon on the device homescreen. The icon in springboard and in other areas of iOS will not change and continue to show the original.

Changing the app icon is only allowed when the app is in the foreground.

Android support is currently in beta. See the android-support branch for more info.

Installation

npm install @capacitor-community/app-icon
npx cap sync

Configuration

Add Alternate Icons

The alternate icons need to be included within the app bundle and referenced in the iOS project Info.plist prior to using this plugin. It is not possible to switch to any icon on the fly without adding it to the iOS project first.

Add the alternate icons directly to your iOS project or in a subdirectory.

Setup Info.plist

Add the CFBundleIcons key to Info.plist with CFBundleAlternateIcons dictionary. Each alternate icon needs to be specified.

Providing every resolution for each alternative is not required. By including the icon with the highest supported resolution, iOS will handle the other resolutions by scalling down the large one provided.

From Apple:

When specifying icon filenames, it is best to omit any filename extensions. Omitting the filename extension lets the system automatically detect high-resolution (@2x) versions of your image files using the standard-resolution image filename. If you include filename extensions, you must specify all image files (including the high-resolution variants) explicitly. The system looks for the icon files in the main resources directory of the bundle.

<key>CFBundleIcons</key>
<dict>
  <key>CFBundleAlternateIcons</key>
  <dict>
    <!-- The names to reference in your code -->
    <key>ionic-icon</key>
    <dict>
      <key>UIPrerenderedIcon</key>
      <true/>
      <key>CFBundleIconFiles</key>
      <array>
        <!-- Filenames-->
        <string>ionic-icon</string>
      </array>
    </dict>
    <!-- ... additional alternates if any ... -->
  </dict>
</dict>

Supporting iPad

For iPad specific version of an icon, there is an additional key to add in Info.plist.

<key>CFBundleIcons~ipad</key>
<dict>
  <!-- same as above  -->
</dict>

Usage

import { AppIcon } from '@capacitor-community/app-icon';

const changeIcon = async (iconName) => {

  await AppIcon.change({name: iconName, suppressNotification: true});

}

API

isSupported()

isSupported() => Promise<{value: boolean}>

Checks to see if using alternate icons is supported on your device.


getName()

getName(): Promise<{value: string | null}>;

Gets the name of currently set alternate icon. If original icon is set, returns null.


change(...)

change(options: IconOptions): Promise<void>;

Changes app icon to specified alternate.

Param Type
options IconOptions

reset(...)

reset(options: ResetOptions): Promise<void>;

Changes app icon to specified alternate.

Param Type
options ResetOptions

Interfaces

IconOptions

Represents the options passed to change.

Prop Type Description Since
name string Name of alternate icon to set. 1.0.0
suppressNotification boolean Flag controlling the in app notification which shows after icon is changed. 1.0.0

ResetOptions

Represents the options passed to reset.

Prop Type Description Since
suppressNotification boolean Flag controlling the in app notification which shows after icon is changed. 1.0.0

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

John Borges
John Borges

๐Ÿ’ป
Simon Grimm
Simon Grimm

๐Ÿ’ป
Christian von Rohr
Christian von Rohr

๐Ÿ’ป
QliQ.dev
QliQ.dev

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

app-icon's People

Contributors

johnborges avatar allcontributors[bot] avatar dependabot[bot] avatar saimon24 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.