我正在尝试使用NativeScript Angular构建一个Android应用程序,我正在尝试使用[nativescript-firebase-plugin](https://github.com/EddyVerbruggen/nativescript-plugin-firebase)合并Admob广告 .

我已经创建了一个firebase服务,我将其注入到我的组件中

这是我的服务代码

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: 100,
          top: 0
        },
        androidBannerId: "ca-app-pub-XXXXXXXXXXXXXXX/YYYYYYYYYY",
        // iosBannerId: "ca-app-pub-9517346003011652/3985369721",
        testing: true // when not running in production set this to true, Google doesn't like it any other way
        // iosTestDeviceIds: [ //Android automatically adds the connected device as test device with testing:true, iOS does not
        //     "45d77bf513dfabc2949ba053da83c0c7b7e87715", // Eddy's iPhone 6s
        //     "fee4cf319a242eab4701543e4c16db89c722731f"  // Eddy's iPad Pro
        // ]
      }).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({
            // iosInterstitialId: "ca-app-pub-9517346003011652/6938836122",
            androidInterstitialId: "ca-app-pub-XXXXXXXXXXXXXXX/YYYYYYYYYY",
            testing: true // when not running in production set this to true, Google doesn't like it any other way
            // iosTestDeviceIds: [ // Android automatically adds the connected device as test device with testing:true, iOS does not
            //     "45d77bf513dfabc2949ba053da83c0c7b7e87715", // Eddy's iPhone 6s
            //     "fee4cf319a242eab4701543e4c16db89c722731f"  // Eddy's iPad Pro
            // ]
          }).then(
              function () {
                console.log("AdMob interstitial showing");
              },
              function (errorMessage) {
                console.log("Error - " + errorMessage);
              }
          );
    }
}

以下是我在ngOnInit()中的组件中调用它的方法 . 请注意,我已将这两种方法称为仅用于测试目的 .

setTimeout(() => {
        this.firebaseService.showBanner();
        this.firebaseService.showInterstitial();
    },2000);

启动Admob时我没有收到任何错误 . 但是也没有退回承诺 . 我的日志总是给我以下信息

JS:将此设备作为测试设备处理:0F1D1XXXXXXXXXXXXXXXXXXXXXDD6

有时它会向我提供错误消息

JS:错误 - 3

这个问题是否因为我在androidmanifest.xml中缺少任何权限而出现?有人可以帮忙建议可能的原因吗?