Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reactnativecn/react-native-launch-image
https://github.com/reactnativecn/react-native-launch-image
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/reactnativecn/react-native-launch-image
- Owner: reactnativecn
- Created: 2016-08-12T05:14:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-19T01:13:54.000Z (over 6 years ago)
- Last Synced: 2024-05-22T17:21:02.409Z (about 1 month ago)
- Language: Objective-C
- Size: 11.7 KB
- Stars: 51
- Watchers: 7
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Lists
- react-native-awesome - react-native-launch-image
- awesome-react-native - react-native-launch-image
README
# react-native-launch-image
Only iOS was supported. (for native iOS launch image)
For both iOS&Android support, maybe you can use [rn-splash-screen](https://github.com/mehcode/rn-splash-screen/blob/master/docs/ios.md),
which provides a extra view to contain launch image.> *Notice:* You should not keep launch image more than 5 seconds, which
may cause your app got killed by iOS. To do long-time work(like http
request, which may fail or tooks long), you should first render a react
native page, then hide launch image before work, or set a timeout, hide
launch image even if request is still waiting.## Getting started
`$ npm install react-native-launch-image --save`
### Mostly automatic installation
`$ react-native link react-native-launch-image`
### Manual installation
#### iOS
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-launch-image` and add `RNLaunchImage.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNLaunchImage.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<## Usage
#### iOS
You should add following code to `AppDelegate.m` for keeping launch image:
```obj-c#import "AppDelegate.h"
#import "RCTRootView.h"
#import "RNLaunchImage.h" // <-- Add this line.@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...other code
[RNLaunchImage wait]; // <-- Add this line. This line MUST be the last line of this method.
return YES;
}@end
```
#### Javascript
Use RNLaunchImage.hide() to hide launch image manually.```javascript
import * as launchImage from 'react-native-launch-image';class App extends React.Component {
async componentDidMount(){
// do anything while launch image keeps, use await to wait for an async task.
launchImage.hide();
}
}
```