Skip to content

vocsyinfotech/VocsyFacebookAds

Repository files navigation

VocsyFacebookAds

Facebook Ads Integration

Features

  • Interstitial
  • Banner
  • Native
  • Native Banner


Step 1. Add the JitPack repository to your build file

allprojects {
        repositories {

            maven { url 'https://jitpack.io' }
        }
    }
 Step 2. Add the dependency

dependencies {
     implementation 'com.github.vocsyinfotech:VocsyFacebookAds:0.1.4'
    }

FacebookInterstitial :

 

initialize variable =>

 

FacebookInterstitial facebookInterstitial;

 

Load Interstitial in onCreate();

// LOAD FACEBOOK Interstitial
facebookInterstitial = new FacebookInterstitial(this, getString(R.string.facebook_interstitialAd_id));
facebookInterstitial.loadInterstitialAds(new FacebookInterstitial.ActionListener() {
@Override
public void performAction() {

// do here your action after Facebook Ads Closed
}
});

 

Show Interstitial  Ads

// SHOW FACEBOOK Interstitial
facebookInterstitial.ShowinterstitialAd(this);
// SHOW FACEBOOK Interstitial END

 

FACEBOOK BANNER

 

XML

 

<LinearLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent" />

 

Java onCreate

 

FacebookBanner.FacebookBannerNormal(this, findViewById(R.id.banner_container), getString(R.string.facebook_banner_id));

you can use  also

FacebookBanner90
FacebookBanner250

FACEBOOK Native

 

XML

 

<com.facebook.ads.NativeAdLayout
android:layout_marginTop="50dp"
android:id="@+id/native_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />

Java onCreate

 

FacebookNative.FacebookNativeNormal(this, findViewById(R.id.native_ad_container), getString(R.string.facebook_native_id));

you can use  also

FacebookNativeSmall
FacebookNativeBanner

 

FACEBOOK Native BANNER

 

XML

 

<com.facebook.ads.NativeAdLayout
android:layout_marginTop="50dp"
android:id="@+id/native_banner_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />

Java onCreate

 

FacebookNative.FacebookNativeBanner(this, findViewById(R.id.native_banner_ad_container), getString(R.string.facebook_native_banner_id));