SilverMob Android SDK allows you to display SilverMob advertisement in your app.
Contents:
- Use SilverMob SDK standalone to display ads in your app
- Integrate SilverMob SDK with your existing Applovin MAX SDK
- Acknowledgments
Root build.gradle
allprojects {
repositories {
...
mavenCentral()
...
}
}
App module build.gradle:
implementation("com.silvermob:silvermob-sdk:2.2.8")
SilverMob.setServerAccountId("YOUR_ACCOUNT_ID")
SilverMob.setShareGeoLocation(true)
SilverMob.setPbsDebug(true)//WARNING: Test mode for SilverMob test banners, disable in production
SilverMob.initializeSdk(applicationContext) { status ->
if (status == InitializationStatus.SUCCEEDED) {
Log.d(TAG, "SDK initialized successfully!")
} else {
Log.e(TAG, "SDK initialization error: $status\n${status.description}")
}
}
Code for the small banner integration:
// 1. Create an Ad View
bannerView = BannerView(requireContext(), SILVERMOB_SDK_AD_UNIT, AdSize(WIDTH, HEIGHT))
bannerView?.setBannerListener(this)
// Add view to viewContainer
viewContainer?.addView(bannerView)
adView?.setAutoRefreshDelay(refreshTimeSeconds)
// 2. Load ad
bannerView?.loadAd()
Code for interstitial integration:
// 1. Create an Interstitial Ad Unit
interstitialAdUnit = InterstitialAdUnit(this, SILVERMOB_SDK_AD_UNIT, EnumSet.of(AdUnitFormat.BANNER,AdUnitFormat.VIDEO))
interstitialAdUnit?.setMinSizePercentage(AdSize(50,50)) //Set minimum % of screen ad should occupy
//2. Set load listener
interstitialAdUnit?.setInterstitialAdUnitListener(object : InterstitialAdUnitListener {
override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit?) {
interstitialAdUnit?.show() //Show the ad
}
override fun onAdDisplayed(interstitialAdUnit: InterstitialAdUnit?) {}
override fun onAdFailed(interstitialAdUnit: InterstitialAdUnit?, e: AdException?) {}
override fun onAdClicked(interstitialAdUnit: InterstitialAdUnit?) {}
override fun onAdClosed(interstitialAdUnit: InterstitialAdUnit?) {}
})
// 3. Load Ad
interstitialAdUnit?.loadAd()
Note: Pay attention that the loadAd() should be called on the main thread.
Code for rewarded video integration:
// 1. Create an Ad Unit
adUnit = RewardedAdUnit(this, SILVERMOB_SDK_AD_UNIT)
//2. Set load listener
val rewardedAdUnitListener = adUnit?.setRewardedAdUnitListener(object :
RewardedAdUnitListener {
override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit?) {
adUnit?.show()
}
override fun onAdDisplayed(rewardedAdUnit: RewardedAdUnit?) {}
override fun onAdFailed(rewardedAdUnit: RewardedAdUnit?,exception: AdException?) {}
override fun onAdClicked(rewardedAdUnit: RewardedAdUnit?) {}
override fun onAdClosed(rewardedAdUnit: RewardedAdUnit?) {}
override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?) {}
})
// 3. Load Ad
adUnit?.loadAd()
This guide assumes you already have Applovin MAX SDK correctly integrated.
implementation("com.silvermob:silvermob-sdk:2.2.8")
implementation("com.silvermob:silvermob-sdk-max-adapters:2.2.8")
-
In your Applovin dashboard open MAX > Manage > Networks and scroll to the bottom of the page. Select "Click here to add a Custom Network".
-
Fill out network data as shown on the screenshot. Custom Network Name
SilverMob
, iOS Adapter Class NameSilverMobMaxMediationAdapter
, Android Adapter Class Namecom.applovin.mediation.adapters.SilverMobMaxMediationAdapter
. Note: don't leave iOS adapter name empty or adapter integration might not work. -
Enable SilverMob network for your Ad Units: go to ad unit waterfall settings, scroll to "Custom Networks", enable SilverMob and adjust settings accordingly. Add your SilverMob ad unit id in "Placement ID" for your placement. Supported ad types: Banner, Interstitial, MREC, Rewarded. Wait around 60 minutes for Applovin to update Ad Unit and Network changes.
Note: mediation adapters don't work in Test Mode, be sure to disable it for testing mediation.
This project is based on a fork of Prebid Mobile Android SDK, licensed under the Apache License 2.0. We are grateful to the original authors for their work and contributions to the open-source community.