Display splash ad on React Native

Step 1. Add resources

Replace your init activity, unit id

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="adrop_splash_ad_next_activity" translatable="false">{your_init_activity}</string> <!-- com.company.app.MainActivity -->
    <string name="adrop_splash_ad_unit_id" translatable="false">{your_splash_unit_id}</string> <!-- PUBLIC_TEST_UNIT_ID_SPLASH for test -->
    <integer name="adrop_splash_ad_max_timeout">1000</integer> <!-- (optional) default 1s -->
</resources>

- values/theme.xml

replace parent to your application theme

<style 
    name="Theme.App.SplashTheme"
    parent="Theme.AppCompat.NoActionBar"/>

- values-v31/theme.xml

  1. Add your logo image (288x288) to drawable and replace windowSplashScreenAnimatedIcon

  2. Replace windowSplashScreenBackground to your splash background color

<style "Theme.App.SplashTheme" parent="Theme.SplashScreen"> 
    <item name="windowSplashScreenAnimatedIcon">@drawable/your_logo</item>
    <item name="windowSplashScreenBackground">#ffffff</item>
    <item name="windowSplashScreenAnimationDuration">200</item>
    <item name="postSplashScreenTheme">@style/Theme.App.SplashTheme.TranslucentStatus</item>
</style>

<style name="Theme.App.SplashTheme.TranslucentStatus" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
</style>

Step 2. Update Androidmanifest.xml

<application>
	...
	<activity
	    android:name="io.adrop.ads.splash.AdropSplashAdActivity"
	    android:exported="true"
	    android:theme="@style/Theme.App.SplashTheme"
            tools:replace="android:theme">
	    <intent-filter>
	        <action android:name="android.intent.action.MAIN"/>
	        <category android:name="android.intent.category.LAUNCHER"/>
	    </intent-filter>
	</activity>
	...
</application>

Step 3. Add layout/activity_adrop_splash_ad.xml

  1. Replace your logo path and background color.

  2. Do not remove adrop_splash_ad_image ImageView for splash ad

Step 4. run android (debug)

react-native run-android --main-activity io.adrop.ads.splash.AdropSplashAdActivity

Last updated