AdsHelper Android is a light weight library that enables developers to integrate Ads in a fast and secure fashion. Currently this SDK supports Google AdMob and Facebook Ads network. Keeping coming back from amazing updates and new Ad networks.
Here we have an overview of how you can start integrating this SDK into your app:
implementation 'com.github.sofittech:AdsHelper-Android:x.y.z'
implementation 'com.github.sofittech:AdsHelper-Android:x.y.z-FACEBOOK'
maven { url 'https://jitpack.io' }
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/admob_app_id" />
<string name="admob_app_id">ca-app-pub-3940256099942544~3347511713</string>
private fun setAds() {
if (BuildConfig.DEBUG) {
AdsHelper.Builder(context = applicationContext)
.with(applicationContext)
.isVerified(BuildConfig.DEBUG)
.fbInterstitialID(applicationContext.getString(R.string.fb_test_id_interstitial))
.fbBannerId(applicationContext.getString(R.string.fb_test_id_banner))
.build()
} else if (UtilsID.verifyInstallerId(applicationContext)) {
AdsHelper.Builder(context = applicationContext)
.with(applicationContext)
.isVerified(UtilsID.verifyInstallerId(applicationContext))
.fbBannerId(applicationContext.getString(R.string.fb_id_banner))
.fbInterstitialID(applicationContext.getString(R.string.fb_id_interstitial))
.build()
}
}
And build ads as required (AdMob, Facebook) and (Banner, Interstitial and native ad) in builder class as shown.
fun verifyInstallerId(context: Context): Boolean {
val validInstallers: List<String> =
ArrayList(listOf("com.android.vending"))
val installer = context.packageManager.getInstallerPackageName(context.packageName)
return installer != null && validInstallers.contains(installer)
}
<com.sofit.adshelper.customViews.BannerAdView
android:id="@+id/bannerAdContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="invisible"
app:setTopBorder="true" />
AdsHelper.showFacebookBanner(MainActivity.this, findViewById(R.id.bannerAdContainer)); //Facebook Banner
AdsHelper.showAdMobBanner(MainActivity.this, findViewById(R.id.bannerView)); //Admob Banner
AdsHelper.loadFacebookInterstitial(false);
// The parameter “false” in the above function ask for auto load ad next time (in 15 seconds)
AdsHelper.loadAdMobInterstitial(false)
AdsHelper.showInterstitialAd(MainActivity.this, AdNetwork.Facebook);
// The second argument will bb your preferred network type for the interstital ad.