npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

voyager-capacitor-app-icon

v4.1.0

Published

Capacitor community plugin for changing an iOS app icon.

Downloads

6

Readme

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 will not change and continue to show the original. (iOS)

Changing the app icon is only allowed when the app is in the foreground (iOS).

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

The alternate icons need to be included within the app bundle and referenced in the project prior to using this plugin. It is not possible to switch to any icon on the fly without adding it to the project first. Below are the configurations steps for each platform.

Android Configuration

Add Alternate Icons

Add the alternate icons directly to your android project in app/src/main/res.

Setup ApplicationManifest.xml

Each alternate icon is represented by an <activity-alias>. Add all the alternative icons to the ApplicationManifest.xml as child elements under <application>. The name attribute on <activity-alias> must be prefixed with dot . See ApplicationManifest.xml for full example.

<application>
    <!-- ... -->
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTask"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
        android:label="@string/title_activity_main"
        android:theme="@style/AppTheme.NoActionBarLaunch">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
        </intent-filter>

    </activity>
    <activity-alias
        android:label="Stencil"
        android:icon="@drawable/stencil"
        android:roundIcon="@drawable/stencil"
        android:name=".stencil"
        android:enabled="true"
        android:exported="true"
        android:targetActivity=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>
  
  <!-- additional <activity-alias> -->

<application>

iOS Configuration

Add Alternate Icons

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});
}

const getName = async () => {
  const { value } = await AppIcon.getName();
  console.log(value);
}

const resetIcon = async () => {
  const disable: string[] = ['stencil']; // all added aliaces names 
  await AppIcon.reset({ suppressNotification: true, disable });
}

API

isSupported()

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

Checks if changing the app icon is supported. (iOS only)

Returns: Promise<{ value: boolean; }>

Since: 1.0.0


getName()

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

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

Returns: Promise<{ value: string | null; }>

Since: 1.0.0


change(...)

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

Changes app icon to specified alternate.

| Param | Type | | ------------- | --------------------------------------------------- | | options | IconOptions |

Since: 1.0.0


reset(...)

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

Reverts app icon to original.

| Param | Type | | ------------- | ----------------------------------------------------- | | options | ResetOptions |

Since: 1.0.0


Interfaces

IconOptions

| Prop | Type | Description | Since | | -------------------------- | --------------------- | --------------------------------------------------------------------------------- | ----- | | name | string | Name of alternate icon to set | | | disable | string[] | Name of icons to disable. This is not used for iOS, but required for Android. | 3.1.0 | | suppressNotification | boolean | Flag controlling the in app notification which shows after icon is changed. (iOS) | |

ResetOptions

| Prop | Type | Description | Since | | -------------------------- | --------------------- | --------------------------------------------------------------------------------- | ----- | | suppressNotification | boolean | Flag controlling the in app notification which shows after icon is changed (iOS). | | | disable | string[] | Name of icons to disable. This is not used for iOS, but required for Android. | 3.1.1 |

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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