EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 445 forks source link

ads not showing up #630

Open phatakrajan opened 6 years ago

phatakrajan commented 6 years ago

I have followed all instructions as mentioned in the document. I do not see any ads even though there is no error shown. However interesting point is that i don't get the console message for success as well. Just see the message that my device is added as a Test Device. Is there anything to be done. What am i may be missing. Here is my code.

`import { Injectable } from "@angular/core"; import firebase = require("nativescript-plugin-firebase"); import { Message } from "nativescript-plugin-firebase"; import * as dialogs from "ui/dialogs";

@Injectable() export class FirebaseService { public constructor() { firebase.init({ onMessageReceivedCallback: (message: Message) => { console.log(Title: ${message.title}); console.log(Body: ${message.body}); // if your server passed a custom property called 'foo', then do this: console.log(Value of 'foo': ${message.data.foo}); }, onPushTokenReceivedCallback: function (token) { console.log("Firebase push token: " + token); // this.add(token); } }).then( instance => { console.log("firebase.init done"); }, error => { console.log(firebase.init error: ${error}); } ); }

public showBanner() {
    firebase.admob.showBanner({
        size: firebase.admob.AD_SIZE.SMART_BANNER, // see firebase.admob.AD_SIZE for all options
        margins: { // optional nr of device independent pixels from the top or bottom (don't set both)
            bottom: 10,
        },
        androidBannerId: "ca-app-pub-XXXXXXXXXXX/YYYYYY",
        testing: true // when not running in production set this to true, Google doesn't like it any other way
    }).then(
        function () {
            console.log("AdMob banner showing");
        },
        function (errorMessage) {
            console.log("Error - " + errorMessage);
            // dialogs.alert({
            //   title: "AdMob error",
            //   message: errorMessage,
            //   okButtonText: "Hmmkay"
            // });
        }
    );
}

public showInterstitial() {
    firebase.admob.showInterstitial({
        androidInterstitialId: "ca-app-pub-XXXXXXXXXXX/YYYYYY",
        testing: true // when not running in production set this to true, Google doesn't like it any other way
    }).then(
        function () {
            console.log("AdMob interstitial showing");
        },
        function (errorMessage) {
            console.log("Error - " + errorMessage);
        }
    );
}

} `

I am inserting this service in my components and calling functions to show Banner and Interstitial ads. Does it require any permissions to be added to the androidmanifest file? Logs that i always get is

JS: Treating this deviceId as testdevice: 0F1D18B84D1XXXXXXXXXXXXXXXXXDD6 JS: Treating this deviceId as testdevice: 0F1D18B84D1XXXXXXXXXXXXXXXXXDD6

when i call showBanner and showInterstitial function

mehyaa commented 6 years ago

I could not make admob work either. Seems like it is getting the ad but can not show on page.

I'm using FlexboxLayout as main layout on the page, can that be related?

simonettoa commented 6 years ago

@phatakrajan @mehyaa didi you solve this issue? I'm facing the same problem?

mehyaa commented 6 years ago

They started to show after some time actually, without changing anything. I think it is related to AdMob somehow.

phatakrajan commented 6 years ago

@simonettoa It started showing up for me after some time too