SDK Integration

To integrate tapsouq sdk and show ads in your app follow the following steps:

To get tapsouq library into your build:
Step 1: Add the JitPack repository in your root build.gradle at the end of repositories:
									allprojects {
									    repositories {
									        ...
									        maven { url 'https://jitpack.io' }
									    }
									}
								
Step 2: Add tapsouq dependency to your app build.gradle
									dependencies {
									    ....
									    compile 'com.github.tapsouq:tapsouq-sdk:1.07'
									}
								
Banner Ad Integration:
  1. Login to your account and Add new app, then add new Ad unit (select banner format) and keep the Ad Unit ID to be used in step c.
  2. add xml tag of tapsouq banner.
    											<com.tapsouq.sdk.ads.TapSouqBannerAd
    											    android:role="tabpanel" class="tab-pane" id="@+id/banner_view"
    											    android:layout_width="match_parent"
    											    android:layout_height="wrap_content"/>
    										
  3. In your Activity add the following line of codes:
    											// define the string field adUnitId
    											private String adUnitId = "8";
    											...
    											//add banner code in your activity onCreate() method
    											TapSouqBannerAd banner = (TapSouqBannerAd) findViewById(R.id.banner_view);
    											banner.setAdUnitID(adUnitId);
    											banner.load();
    										
  4. For testing purposes, you must set banner test mode before banner.load().
    											banner.setTestMode(true); //remove this line before publishing
    										
Interstitial Ads Integration:
									public class MainActivity extends AppCompatActivity {

									    private String interstitialAdUnit = "12";

									    @Override
									    protected void onCreate(Bundle savedInstanceState) {
									        super.onCreate(savedInstanceState);
									        setContentView(R.layout.activity_main);


									        final TapSouqInterstitialAd interstitialAd = new TapSouqInterstitialAd(this);
									        interstitialAd.setAdUnitID(interstitialAdUnit);
									        interstitialAd.setListener(new TapSouqListener() {
									            @Override
									            public void adLoaded() {
											    if(interstitialAd.isAdLoaded()){
									                 interstitialAd.showAd();
											    }
									            }
											//you can override other methods 
									 		// like adShown(), adClicked(), adClosed(), AdFailed()
									        });
									        interstitialAd.load();

									    }
									}
								
Also you can add setTestMode(true) with interstitial ad.
(Optional) Add Listener:
If you want to add listener to track when the Ad is (loaded, shown, clicked, failed, or closed) put this code before loading the banner or interstitial:
									interstitialAd.setListener(new TapSouqListener(){
									//You can override one or more method
							            @Override
							            public void adLoaded() {
							            }

							            @Override
							            public void adClosed() {
							            }

							            @Override
							            public void adFailed() {
							            }

							            @Override
							            public void adClicked() {
							            }

							            @Override
							            public void adShown() {
							            }

							        });						
								
(Optional) How to integrate tapsouq ads with admob:
You can put tapsouq Ads directly in your app and/or you can integrate them with admob. When admob ads are failed to load you can simply call tapsouq ads.
									admobInterstitialAd = new InterstitialAd(this);
									admobInterstitialAd.setAdUnitId(admobAdUnitId);
									admobInterstitialAd.setAdListener(new AdListener() {

									    @Override
									    public void onAdFailedToLoad(int errorCode) {

									        final TapSouqInterstitialAd interstitialAd = new TapSouqInterstitialAd(this);
									        interstitialAd.setAdUnitID(tapsouqAdUnitId);
									        interstitialAd.setListener(new TapSouqListener() {
									            @Override
									            public void adLoaded() {
									                if (interstitialAd.isAdLoaded()) {
									                    interstitialAd.showAd();
									                }
									            }
									            //you can override other methods, if you need 
									            // like adShown(), adClicked(), adClosed(), AdFailed()
									        });


									        super.onAdFailedToLoad(errorCode);
									    }
									});

									admobInterstitialAd.loadAd(new AdRequest.Builder().build());