Ionic Facebook ads

Hi. I just finished my Ionic app and now I want to add some ads. I’ve installed the plugin for Facebook ads but I’m having some problems.

  1. The interstitial is loaded even if I’m outside the app. This is very bad.
  2. If one interstitial is loaded and I wait another 2 minutes, another interstitial is loaded over the 1st. ( I load the interstitial at each 2 minutes )

I’ve added the code in app.component.ts

declare var FacebookAds: any;
 platform.ready().then(() => {
setInterval( () => { 
          let options = {
            adId: 'native_code_id'
          FacebookAds.prepareInterstitial(options, function(data){
          }, function(err){})
      }, 1000 * 60 * 2);
  1. Native ads is looking bad until it loads. How can I make the div visible only when ad is ready.
  start: any = 0;       
 if(FacebookAds) {
          this.start = 1;
        document.addEventListener("onAdLoaded", function(data){
          let temp: any = data;
          if(temp.adType == "native")
            document.getElementById('adIcon').setAttribute("src", temp.adRes.icon.url);
            document.getElementById('adCover').setAttribute("src", temp.adRes.coverImage.url);
            document.getElementById('adTitle').innerHTML = temp.adRes.title;
            document.getElementById('adBody').innerHTML = temp.adRes.body;
            document.getElementById('adSocialContext').innerHTML = temp.adRes.socialContext;
            document.getElementById('adBtn').innerHTML = temp.adRes.buttonText;

and in home/id.html

	<span id="native" *ngIf="start != 0">
			<img src="" id="adCover" style="max-width: 100%; height: auto;" />
			<ion-card-content text-wrap>
					<ion-avatar item-left>
						<img src="" id="adIcon" />
					<h2 id="adTitle"></h2>
					<p id="adBody"></p>
					<ion-col center text-left width-70 small style="font-size: x-small;">
						<span id="adSocialContext" small></span>
					<ion-col center text-right width-30>
							<button ion-button small color="primary" id="adBtn"></button>

4. I wanted to add the code in app.component.ts once for native ads and to use it everywhere in my app. How it’s possible? Right now I’m using it only on specific view. Also right now I’m facing another problem. If I go from home.html to home/id.html is working but if I go from /home/id.html to home/id2.html the ad is not working. It appears like in the
top image .

Thank you!

Which plugin did u use for facebook ads, and how do we apply for it ?

For native ads

and for banner and interstitial

i had no previuos experience with Fb ads, just asking, can we earn from fb ads ? like admob

Yes :slight_smile: I’m using facebook ads on my website also.

is there any update in this ??

you can contact in fiveer and serch by username called Nautam, they will provide service for facebook ads integration in ionic app