Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
rn-dynamic-app-icon
Advanced tools
Programmatically change the app icon in React Native for both android and iOS.
NPM:
npm install rn-dynamic-app-icon
YARN:
yarn add rn-dynamic-app-icon
cd ios && pod install
1. Android
android/app/src/main/res/mipmap-*
directories:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rndynamicappicon">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/sd"
android:label="@string/app_name"
android:roundIcon="@mipmap/sd_round"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<activity-alias
android:name=".MainActivityAU"
android:enabled="false"
android:icon="@mipmap/au"
android:roundIcon="@mipmap/au_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityCA"
android:enabled="false"
android:icon="@mipmap/ca"
android:roundIcon="@mipmap/ca_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityUK"
android:enabled="false"
android:icon="@mipmap/uk"
android:roundIcon="@mipmap/uk_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name=".MainActivityUS"
android:enabled="false"
android:icon="@mipmap/us"
android:roundIcon="@mipmap/us_round"
android:targetActivity=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
</application>
</manifest>
The main point is to create tags to make more alternate icons. While the tag name should be your applications initial Activity name suffixed by you icon definition name example: .MainActivityAU NOTE: Default icon will have the initial Activity's name, example: .MainActivity
2. iOS
<key>CFBundleIcons</key>
<dict>
<key>CFBundleAlternateIcons</key>
<dict>
<key>AU</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>AU</string>
</array>
</dict>
<key>CA</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>CA</string>
</array>
</dict>
<key>UK</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>UK</string>
</array>
</dict>
<key>US</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>US</string>
</array>
</dict>
</dict>
</dict>
Now the Info.plist file should look as follows:
import { changeIcon } from "rn-dynamic-app-icon";
// ...
// Pass the name of icon to be enabled
changeIcon('US');
// Pass an empty string to enable default icon
changeIcon('');
// Android ONLY
// Pass package name from js level incase you are having
// different packages on your app:
// OR
// For any reason, your initial activity is not MainActivity.
const packageName = 'com.exampleapp.SplashActivity';
changeIcon('US', packageName);
To @skb1129 for his work on a similar project which inspired me to implement this package with a bit of enhancements on both android and ios
To freepik, since all of the icons used in this projects are made by https://www.freepik.com
FAQs
Programmatically change the React Native app icon
The npm package rn-dynamic-app-icon receives a total of 15 weekly downloads. As such, rn-dynamic-app-icon popularity was classified as not popular.
We found that rn-dynamic-app-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.