Start.io (Formerly StartApp) ad SDK for react-native
- React Native v0.78.0 or higher
- Node 18.0.0 or higher
Note
Since react-native-start-io-sdk is built with Nitro Views, it requires the new architecture to be enabled.
npm install react-native-start-io-sdk react-native-nitro-modulesor
yarn add react-native-start-io-sdk react-native-nitro-modulesor
pnpm add react-native-start-io-sdk react-native-nitro-modulesthen
cd ios && pod install
Initializes the Start.io SDK with your application IDs for both Android and iOS.
This must be called once before loading or showing any ads.
Parameters (InitializeSdkParams):
androidAppId(required) — Your Start.io application ID for Android.iOSAppId(required) — Your Start.io application ID for iOS.testAd?— Optional. Set totrueto load test ads instead of live ads. Default:false.returnAd?— (deprecated) Optional. Set tofalseto disable return ads. Default:true.adPreferences?— Optional. Target ads by user demographics:age?— User's age.gender?—AdPreferencesGender.MALEorAdPreferencesGender.FEMALE.
Note
At least one of androidAppId or iOSAppId is required.
Example:
import { initializeStartIoSdk, AdPreferencesGender } from 'react-native-start-io-sdk';
// Initialize with live ads
initializeStartIoSdk({
androidAppId: 'ANDROID_APP_ID',
iOSAppId: 'IOS_APP_ID'
});
// Initialize with test ads and return ads disabled
initializeStartIoSdk({
androidAppId: 'ANDROID_APP_ID',
iOSAppId: 'IOS_APP_ID',
testAd: true,
returnAd: false
});
// Initialize with ad preferences (demographic targeting)
initializeStartIoSdk({
androidAppId: 'ANDROID_APP_ID',
iOSAppId: 'IOS_APP_ID',
adPreferences: {
age: 25,
gender: AdPreferencesGender.MALE
}
});You must load an ad before you can show it. The loadAd function accepts an AdType to specify which ad format to request. Supported (non-deprecated) types are:
-
AdType.AUTOMATIC— Let the SDK choose the best ad type. -
AdType.FULLPAGE— Fullscreen interstitial ad. -
AdType.VIDEO— Standard video ad. -
AdType.REWARDED_VIDEO— Rewarded video ad (grants a reward on completion).
await loadAd(AdType.REWARDED_VIDEO);
showAd((result) => {
if (result === AdResultType.AdRewarded) {
console.log('User earned a reward!');
}
});loadAd(AdType.REWARDED_VIDEO).then(() => {
showAd((result) => {
if (result === AdResultType.AdRewarded) {
console.log('User earned a reward!');
}
});
});loadAd(AdType.AUTOMATIC).then(() => {
showAd((result) => {
console.log('Ad finished with result:', result);
});
});loadAd(AdType.FULLPAGE).then(() => {
showAd((result) => {
if (result === AdResultType.AdClicked) {
console.log('User clicked the interstitial ad');
}
});
});loadAd(AdType.VIDEO).then(() => {
showAd((result) => {
if (result === AdResultType.AdHidden) {
console.log('Video ad closed by user');
}
});
});<StartIoBannerAd
adTag="home_banner"
onReceiveAd={() => console.log('Banner loaded')}
onClick={() => console.log('Banner clicked')}
style={{ marginBottom: 10 }}
/><StartIoMrecAd
adTag="article_mrec"
onReceiveAd={() => console.log('MREC loaded')}
style={{ alignSelf: 'center', marginVertical: 20 }}
/><StartIoCoverAd
adTag="landing_cover"
onReceiveAd={() => console.log('Cover loaded')}
style={{ marginTop: 15 }}
/>Use loadNativeAds to fetch native ad data, then render your own UI and overlay StartIoNativeAdTouchArea to handle clicks natively.
Important
Do not handle touch/click events from views within your native ad layout. All clicks are managed natively by StartIoNativeAdTouchArea.
import { loadNativeAds, NativeAdImageSize } from 'react-native-start-io-sdk';
// Load up to 3 native ads with default image sizes
const ads = await loadNativeAds(3);
// Load with custom image sizes
const ads = await loadNativeAds(
5,
NativeAdImageSize.SIZE_340X340,
NativeAdImageSize.SIZE_340X340
);NativeAdImageSize values: SIZE_72X72, SIZE_100X100, SIZE_150X150 (default), SIZE_340X340, SIZE_1200X628
Note
SIZE_1200X628 is only supported for primaryImageSize. If used as secondaryImageSize, the default (SIZE_150X150) will be used instead.
Tip
Don't reload native ads too frequently — a 45-second interval (matching the default banner refresh rate) is recommended.
Place StartIoNativeAdTouchArea as an absolutely positioned overlay inside your ad container. Pass the adIndex matching the ad's position in the array returned by loadNativeAds.
import React, { useEffect, useState } from 'react';
import { View, Text, Image, Button, StyleSheet } from 'react-native';
import {
loadNativeAds,
StartIoNativeAdTouchArea,
NativeAdDetails
} from 'react-native-start-io-sdk';
export const NativeAdExample = () => {
const [nativeAds, setNativeAds] = useState<NativeAdDetails[]>([]);
useEffect(() => {
loadNativeAds(3).then(setNativeAds);
}, []);
return (
<View>
{nativeAds.map((adData, index) => (
<View key={index} style={{ position: 'relative', width: 300, height: 250 }}>
<View style={styles.adContainer}>
{adData.imageUrl && (
<Image source={{ uri: adData.imageUrl }} style={styles.image} />
)}
<Text style={styles.title}>{adData.title}</Text>
<Text style={styles.description}>{adData.description}</Text>
{/* Click is handled natively — do not attach onPress */}
<Button title={adData.callToAction} onPress={() => {}} />
</View>
{/* Overlay to capture native clicks */}
<StartIoNativeAdTouchArea adIndex={index} />
</View>
))}
</View>
);
};
const styles = StyleSheet.create({
adContainer: { flex: 1, padding: 8, backgroundColor: '#fff' },
image: { width: '100%', height: 150, resizeMode: 'cover' },
title: { fontWeight: 'bold', fontSize: 16, marginTop: 8 },
description: { fontSize: 14, color: '#555', marginVertical: 4 },
});Warning
StartIoNativeAd is deprecated. Use loadNativeAds + StartIoNativeAdTouchArea instead.
import React, { useState } from 'react';
import { View, Text, Image, Button, StyleSheet } from 'react-native';
import { StartIoNativeAd, NativeAdDetails } from 'react-native-start-io-sdk';
export const NativeAdExample = () => {
const [adData, setAdData] = useState<NativeAdDetails | null>(null);
return (
<View style={{ position: 'relative', width: 300, height: 250 }}>
{adData && (
<View style={styles.adContainer}>
{adData.imageUrl && (
<Image source={{ uri: adData.imageUrl }} style={styles.image} />
)}
<Text style={styles.title}>{adData.title}</Text>
<Text style={styles.description}>{adData.description}</Text>
{/* Click is handled natively — do not attach onPress */}
<Button title={adData.callToAction} onPress={() => {}} />
</View>
)}
<StartIoNativeAd
onLoadAd={(data) => setAdData(data)}
onLoadError={(err) => console.error('Native ad error:', err)}
/>
</View>
);
};
const styles = StyleSheet.create({
adContainer: { flex: 1, padding: 8, backgroundColor: '#fff' },
image: { width: '100%', height: 150, resizeMode: 'cover' },
title: { fontWeight: 'bold', fontSize: 16, marginTop: 8 },
description: { fontSize: 14, color: '#555', marginVertical: 4 },
});Use setUserConsent to set the user consent for personalized ads.
import { setUserConsent } from 'react-native-start-io-sdk';
// Set user consent for personalized ads
setUserConsent(Date.now(), true);Use setIABUSPrivacyString to set the IAB US Privacy String for personalized ads.
import { setIABUSPrivacyString } from 'react-native-start-io-sdk';
// Set IAB US Privacy String
setIABUSPrivacyString('1YNY');| Function | Description |
|---|---|
initializeStartIoSdk(params) |
Initialize the SDK. Must be called once before loading any ads. |
loadAd(adType?) |
Load an interstitial/video ad. Defaults to AdType.AUTOMATIC. |
showAd(callback?) |
Show a previously loaded ad. |
loadNativeAds(numberOfAds, primaryImageSize?, secondaryImageSize?) |
Fetch native ad data. Returns Promise<NativeAdDetails[]>. |
setUserConsent(currentTimeMillis, userConsent) |
Set GDPR user consent. |
setIABUSPrivacyString(iabusPrivacyString) |
Set CCPA IAB US Privacy String. |
| Component | Description |
|---|---|
StartIoBannerAd |
320×50 banner ad. |
StartIoMrecAd |
300×250 medium rectangle ad. |
StartIoCoverAd |
300×157 cover banner ad. |
StartIoNativeAdTouchArea |
Overlay to handle native ad clicks (use with loadNativeAds). |
StartIoNativeAd |
(Deprecated) Legacy native ad click overlay. |
| Enum | Values |
|---|---|
AdType |
AUTOMATIC, FULLPAGE, REWARDED_VIDEO, VIDEO (+ deprecated: OFFERWALL, OVERLAY) |
AdResultType |
AdDisPlayed, AdClicked, AdHidden, AdNotDisplayed, AdRewarded |
AdPreferencesGender |
MALE, FEMALE |
NativeAdImageSize |
SIZE_72X72, SIZE_100X100, SIZE_150X150 (default), SIZE_340X340, SIZE_1200X628 (primary only) |
| Type | Description |
|---|---|
InitializeSdkParams |
Params for initializeStartIoSdk: androidAppId, iOSAppId, testAd, returnAd, adPreferences. |
AdInitPreferences |
{ age?: number; gender?: AdPreferencesGender } |
NativeAdDetails |
Data object for building native ad UI: title, description, rating, imageUrl, secondaryImageUrl, installs, category, packageName, campaignAction, callToAction. |
Bootstrapped with create-nitro-module.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.