# react-native-change-appicon

> Change AppIcon for iOS

Latest version **0.0.5** (published 2018-05-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-change-appicon
pnpm add react-native-change-appicon
yarn add react-native-change-appicon
bun add react-native-change-appicon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2018-05-23 |
| First published | 2018-05-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Elroy |
| Maintainers | elroynmp |
| Keywords | change, AppIcon, iOS |

## Links

- npm: https://www.npmjs.com/package/react-native-change-appicon
- Repository: https://github.com/altncmd/react-native-change-appicon
- Homepage: https://github.com/altncmd/react-native-change-appicon#readme
- Issues: https://github.com/altncmd/react-native-change-appicon/issues
- npm.io page: https://npm.io/package/react-native-change-appicon

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2018-05-23
- 0.0.4 — 2018-05-21
- 0.0.3 — 2018-05-21
- 0.0.2 — 2018-05-21
- 0.0.1 — 2018-05-21

## README

react-native-change-appicon
======
Change app icon for iOS

Installation
------
yarn add react-native-change-appicon<br>
react-native link react-native-change-appicon

Documentation
------
1.Add a `ViewController` to your project as a rootViewController which inherited from `UIViewController` and write the following code in `ViewController.m` file:<br>

```Objective-C
#import "ViewController.h"
#import <objc/runtime.h>

@interface ViewController ()

@end

@implementation ViewController

- (instancetype)init
{
  self = [super init];
  if (self) {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
      Method presentM = class_getInstanceMethod(self.class, @selector(presentViewController:animated:completion:));
      Method presentSwizzlingM = class_getInstanceMethod(self.class, @selector(ox_presentViewController:animated:completion:));
      method_exchangeImplementations(presentM, presentSwizzlingM);
    });
  }
  return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)ox_presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
  if ([viewControllerToPresent isKindOfClass:[UIAlertController class]]) {
    UIAlertController *alertController = (UIAlertController *)viewControllerToPresent;
    if (alertController.title == nil && alertController.message == nil) {
      return;
    } else {
      [self ox_presentViewController:viewControllerToPresent animated:flag completion:completion];
      return;
    }
  }
  [self ox_presentViewController:viewControllerToPresent animated:flag completion:completion];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
```


2.Change the rootViewController at `AppDelegate.m` of your project:
```Objective-C
#import "ViewController.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  UIViewController *rootViewController = [[ViewController alloc] init];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

@end
```

3.Add icons to your project which you want to change to.<br>
(Icons are all in the 'icons' directory in the Example project)

4.Add key-values in the `Info.plist` file like this:<br>
(you should change the icon names `'icon0*.png'` to your own icon names and one-to-one correspondence with pictures from icons directory)<br>

`CFBundlePrimaryIcon`：APP default icon<br>
`CFBundleAlternateIcons`：Alternate icons(All your alternate icons should write here)<br>
`UINewsstandIcon`: news stand icon<br>



your project -> Info.plist -> right click -> Open As -> Source Code:
```Objective-C
  <key>CFBundleIcons</key>
  <dict>
    <key>CFBundleAlternateIcons</key>
    <dict>
      <key>icon01.png</key>
      <dict>
        <key>CFBundleIconFiles</key>
        <array>
          <string>icon01.png</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
      </dict>
      <key>icon02.png</key>
      <dict>
        <key>CFBundleIconFiles</key>
        <array>
          <string>icon02.png</string>
        </array>
        <key>UIPrerenderedIcon</key>
        <false/>
      </dict>
    </dict>
    <key>CFBundlePrimaryIcon</key>
    <dict>
      <key>CFBundleIconFiles</key>
      <array>
        <string>icon01.png</string>
      </array>
      <key>UIPrerenderedIcon</key>
      <false/>
    </dict>
    <key>UINewsstandIcon</key>
    <dict>
      <key>CFBundleIconFiles</key>
      <array>
        <string></string>
      </array>
      <key>UINewsstandBindingEdge</key>
      <string>UINewsstandBindingEdgeLeft</string>
      <key>UINewsstandBindingType</key>
      <string>UINewsstandBindingTypeMagazine</string>
    </dict>
  </dict>
  ```
5.Usage:<br>
```
import ChangeAppIcon from 'react-native-change-appicon';



ChangeAppIcon.changeAppIconWithName('icon02.png');
```

---
_Source: https://npm.io/package/react-native-change-appicon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
