
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
adrop-ads-react-native
Advanced tools
Adrop Ads SDK for React Native
com.android.tools.build:gradle
v7.3.0 or latercompileSdkVersion
33
Before you can add Adrop to your React Native app, you need to create a Adrop project to connect to your app.
To use Adrop in your React Native app, you need to register your app with your Adrop project. Registering your app is often called "adding" your app to your project.
Note
Make sure to enter the package name that your app is actually using. The package name value is case-sensitive, and it cannot be changed for this Adrop Android app after it's registered with your Adrop project.
android/app/src/main/assets/adrop_service.json
From your React Native project directory, run the following command to install the plugin.
npm install adrop-ads-react-native
Altering CocoaPods to use frameworks
Open the file ./ios/Podfile
and add this line inside your targets
use_frameworks!
Note
adrop-ads-react-native uses use_frameworks, which has compatibility issues with Flipper.
Flipper: use_frameworks is not compatible with Flipper. You need to disable Flipper by commenting out the :flipper_configuration line in your Podfile.
Autolinking & rebuilding
Once the above steps have been completed, the React Native Adrop library must be linked to your project and your application needs to be rebuilt.
Users on React Native 0.60+ automatically have access to "autolinking", requiring no further manual installation steps. To automatically link the package, rebuild your project:
# Android apps
npx react-native run-android
# iOS apps
cd ios/
pod install --repo-update
cd ..
npx react-native run-ios
The final step is to add initialization code to your application.
import { Adrop } from 'adrop-ads-react-native';
// ..
Adrop.initialize(production);
# Add this line to your Podfile
use_frameworks!
# ...
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
#...
# Add this line to your Podfile
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
To create a new Ad unit:
The Ad unit’s unique identifier to reference in your code. This setting is read-only.
Note These are unit ids for test
- PUBLIC_TEST_UNIT_ID_320_50
- PUBLIC_TEST_UNIT_ID_375_80
- PUBLIC_TEST_UNIT_ID_320_100
- PUBLIC_TEST_UNIT_ID_INTERSTITIAL
- PUBLIC_TEST_UNIT_ID_REWARDED
- PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM
- PUBLIC_TEST_UNIT_ID_POPUP_CENTER
- PUBLIC_TEST_UNIT_ID_NATIVE
Initialize AdropBanner with Ad unit ID, then load ad.
const YourComponent: React.FC = () => {
const ref = useRef(null)
const reload = () => {
ref.current?.load()
}
return (
<View>
<Button title="reload" onPress={reload}/>
<AdropBanner
ref={ref}
unitId={unitId}
style={{
width: Dimensions.get('window').width,
height: 80
}}
/>
</View>
)
}
Step 1: (Optional) Construct event listener
const listener = {
onAdReceived: (ad: AdropInterstitialAd) =>
console.log(`Adrop interstitial Ad load with unitId ${ad.unitId}!`),
onAdFailedToReceive: (ad: AdropInterstitialAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while load: ${errorCode}`),
onAdFailedToShowFullScreen: (ad: AdropInterstitialAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while showing: ${errorCode}`),
...
}
Step 2: Display an interstitial ad
const YourComponent: React.FC = () => {
const [interstitialAd, setInterstitialAd] = useState<AdropInterstitialAd>(null)
useEffect(() => {
let adropInterstitialAd = new AdropInterstitialAd('YOUR_UNIT_ID')
adropInterstitialAd.listener = listener
adropInterstitialAd.load()
setInterstitialAd(adropInterstitialAd)
}, []);
const show = () => {
if (interstitialAd?.isLoaded) {
interstitialAd?.show()
} else {
console.log('interstitial ad is loading...')
}
}
return (
<View>
<Button title="display ad" onPress={show}/>
</View>
)
}
AdropInterstitialAd must be destroyed of when access to it is no longer needed.
interstitialAd.destroy()
const YourComponent: React.FC = () => {
const { load, show, isLoaded } =
useAdropInterstitialAd('YOUR_UNIT_ID')
const handleShow = () => {
if (isLoaded) show()
}
return (
<View>
<Button title="load ad" onPress={load}/>
<Button title="display ad" onPress={handleShow}/>
</View>
)
}
Step 1: (Optional) Construct event listener
const listener = {
onAdReceived: (ad: AdropRewardedAd) =>
console.log(`Adrop rewarded Ad load with unitId ${ad.unitId}!`),
onAdFailedToReceive: (ad: AdropRewardedAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while load: ${errorCode}`),
onAdFailedToShowFullScreen: (ad: AdropRewardedAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while showing: ${errorCode}`),
onAdEarnRewardHandler: (ad: AdropRewardedAd, type: number, amount: number) =>
console.log(`Adrop rewarded Ad earn rewards: ${ad.unitId}, ${type}, ${amount}`),
...
}
Step 2: Display a rewarded ad
const YourComponent: React.FC = () => {
const [rewardedAd, setRewardedAd] = useState<AdropRewardedAd>(null)
useEffect(() => {
let adropRewardedAd = new AdropRewardedAd('YOUR_UNIT_ID')
adropRewardedAd.listener = listener
adropRewardedAd.load()
setRewardedAd(adropRewardedAd)
}, []);
const show = () => {
if (rewardedAd?.isLoaded) {
rewardedAd?.show()
} else {
console.log('rewarded ad is loading...')
}
}
return (
<View>
<Button title="display ad" onPress={show}/>
</View>
)
}
AdropRewardedAd must be destroyed of when access to it is no longer needed.
rewardedAd.destroy()
const YourComponent: React.FC = () => {
const { load, show, isLoaded } =
useAdropRewardedAd('YOUR_UNIT_ID')
const handleShow = () => {
if (isLoaded) show()
}
return (
<View>
<Button title="load ad" onPress={load}/>
<Button title="display ad" onPress={handleShow}/>
</View>
)
}
Step 1: (Optional) Construct event listener
const listener = {
onAdReceived: (ad: AdropRewardedAd) =>
console.log(`Adrop rewarded Ad load with unitId ${ad.unitId}!`),
onAdFailedToReceive: (ad: AdropRewardedAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while load: ${errorCode}`),
onAdFailedToShowFullScreen: (ad: AdropRewardedAd, errorCode: string) =>
console.log(`error in ${ad.unitId} while showing: ${errorCode}`),
onAdEarnRewardHandler: (ad: AdropRewardedAd, type: number, amount: number) =>
console.log(`Adrop rewarded Ad earn rewards: ${ad.unitId}, ${type}, ${amount}`),
...
}
Step 2: Display a rewarded ad
const YourComponent: React.FC = () => {
const [rewardedAd, setRewardedAd] = useState<AdropRewardedAd>(null)
useEffect(() => {
let adropRewardedAd = new AdropRewardedAd('YOUR_UNIT_ID')
adropRewardedAd.listener = listener
adropRewardedAd.load()
setRewardedAd(adropRewardedAd)
}, []);
const show = () => {
if (rewardedAd?.isLoaded) {
rewardedAd?.show()
} else {
console.log('rewarded ad is loading...')
}
}
return (
<View>
<Button title="display ad" onPress={show}/>
</View>
)
}
AdropRewardedAd must be destroyed of when access to it is no longer needed.
rewardedAd.destroy()
const YourComponent: React.FC = () => {
const [popupAd, setPopupAd] = useState<AdropPopupAd>()
const [isLoaded, setIsLoaded] = useState(false)
useEffect(() => {
let customColors: AdropPopupAdColors = {}
let adropPopupAd = new AdropPopupAd(unitId, customColors)
adropPopupAd.listener = {
onAdReceived: (ad: AdropPopupAd) => {
setIsLoaded(true)
}
}
adropPopupAd.load()
setPopupAd((prev) => {
prev?.destroy()
return adropPopupAd
})
}, [])
const show = () => {
if (popupAd?.isLoaded) {
popupAd?.show()
} else {
console.log('popupAd ad is loading...')
}
}
return (
<View>
<Button title="display ad" onPress={show}/>
</View>
)
}
const YourComponent: React.FC = () => {
const [nativeAd, setNativeAd] = useState<AdropNativeAd>()
const [isLoaded, setIsLoaded] = useState(false)
useEffect(() => {
let adropNativeAd = new AdropNativeAd(unitId)
adropNativeAd.listener = {
onAdReceived: (ad) => {
setIsLoaded(true)
},
}
adropNativeAd.load()
setNativeAd((prev) => {
prev?.destroy()
return adropNativeAd
})
}, [])
const nativeAdView = (
<AdropNativeAdView
nativeAd={nativeAd}
style={...}
>
<View>
<AdropProfileLogoView style={...}/>
<AdropProfileNameView style={...}/>
</View>
<AdropHeadLineView style={...}/>
<AdropBodyView style={...}/>
<AdropMediaView style={...}/>
</AdropNativeAdView>
)
return (
<View>
<Button title="load ad" onPress={load}/>
{isLoaded && nativeAdView}
</View>
)
}
FAQs
Adrop Ads
The npm package adrop-ads-react-native receives a total of 33 weekly downloads. As such, adrop-ads-react-native popularity was classified as not popular.
We found that adrop-ads-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.