Gathering detailed insights and metrics for react-native-app-splash
Gathering detailed insights and metrics for react-native-app-splash
Gathering detailed insights and metrics for react-native-app-splash
Gathering detailed insights and metrics for react-native-app-splash
npm install react-native-app-splash
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Commits
1 Forks
1 Watching
1 Branches
1 Contributors
Updated on 17 May 2024
Kotlin (40.33%)
JavaScript (17.97%)
Ruby (13.94%)
Objective-C (12.31%)
Objective-C++ (12.05%)
TypeScript (2.69%)
C (0.45%)
Swift (0.27%)
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
-80.8%
5
Compared to previous week
Last month
54.2%
37
Compared to previous month
Last year
0%
617
Compared to previous year
2
19
React Native app splash library: programmatically show/hide for Android & iOS.
1$ npm install --save react-native-app-splash
1$ yarn add react-native-app-splash
Android:
android/settings.gradle
file, make the following additions:1include ':react-native-app-splash' 2project(':react-native-app-splash').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-app-splash/android')
:react-native-app-splash
project as a compile-time dependency:1... 2dependencies { 3 ... 4 implementation project(':react-native-app-splash') 5}
iOS:
cd ios
run pod install
Android:
Update the MainActivity.java
to use react-native-app-splash
via the following changes:
java:
1import android.os.Bundle; // here 2import com.appsplash.AppSplash; // here 3 4public class MainActivity extends ReactActivity { 5 @Override 6 protected void onCreate(Bundle savedInstanceState) { 7 AppSplash.show(this); // here 8 super.onCreate(null) // to fix Fragment constructor caused an exception 9 } 10 // ...other code 11}
kotlin:
1import android.os.Bundle; // here 2import com.appsplash.AppSplash; // here 3 4class MainActivity : ReactActivity() { 5 6 override fun onCreate(savedInstanceState: Bundle?) { 7 AppSplash.show(this) 8 super.onCreate(null) // to fix Fragment constructor caused an exception 9 } 10 // ...other code 11}
iOS:
Update AppDelegate.m
with the following additions:
obj-c:
1#import "AppDelegate.h" 2 3#import <React/RCTBundleURLProvider.h> 4#import "AppSplash.h" // here 5 6@implementation AppDelegate 7 8- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 9{ 10 // ...other code 11 [super application:application didFinishLaunchingWithOptions:launchOptions]; 12 [AppSplash show]; // here 13 return YES; 14} 15 16@end 17 18// ...other code 19
Create a file called app_splash.xml
in app/src/main/res/layout
(create the layout
-folder if it doesn't exist). The contents of the file should be the following:
1<?xml version="1.0" encoding="utf-8"?> 2<RelativeLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:id="@+id/_dialog_parent" 6 android:layout_width="match_parent" 7 android:background="@android:color/white" 8 android:layout_height="match_parent"> 9 10 <ImageView 11 android:id="@+id/_dialog_imageview" 12 android:layout_width="match_parent" 13 android:src="@drawable/app_splash" 14 android:layout_centerHorizontal="true" 15 android:layout_centerVertical="true" 16 android:layout_height="match_parent" 17 tools:ignore="ContentDescription" /> 18 19</RelativeLayout>
Customize your launch screen by creating a app_splash.png
-file and placing it in an appropriate drawable
-folder. Android automatically scales drawable, so you do not necessarily need to provide images for all phone densities.
You can create app splashs in the following folders:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
Optional steps:
If you want the app splash to be full screen, Change your show
method.
java/kotlin:
1AppSplash.show(this, true)
Customize your app splash via LaunchScreen.storyboard
or LaunchScreen.xib
。
Use like so:
1import AppSplash from 'react-native-app-splash'; 2 3const App = () => { 4 5 React.useEffect(() => { 6 // do the needed action while app splash is shown 7 // After having done action hide the app splash 8 AppSplash?.hide() 9 }, []) 10 11} 12export default App;
Method | Type | Optional | Description |
---|---|---|---|
show() | function | false | Open App Splash (Native Method ) |
show(final Activity activity, final boolean fullScreen) | function | false | Open App Splash (Native Method ) |
hide() | function | false | Close App Splash |
No vulnerabilities found.
No security vulnerabilities found.