NativeScript / firebase

Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
https://docs.nativescript.org/plugins/firebase-core.html
Apache License 2.0
56 stars 50 forks source link

ERROR TypeError: Could not load view for: BannerAd.Error #263

Open TiagoLaraTecSys opened 4 months ago

TiagoLaraTecSys commented 4 months ago

HEllo!

I'm trying to use BannerAd directive in angular with nativescript/firebase-admob. I'm getting the following error:

Screenshot from 2024-06-24 19-15-00

I already add the AdmobModule to my module component, what i'm doing wrong?

mugifly commented 4 days ago

@TiagoLaraTecSys I also encountered the same error. I hope this will be officially fixed.

As a workaround for now, I was able to display it correctly by writing it as follows:

import { Component } from "@angular/core";
import { registerElement } from "@nativescript/angular";
import { BannerAd, BannerAdSize } from "@nativescript/firebase-admob";

registerElement("BannerAd", () => {
  return require("@nativescript/firebase-admob").BannerAd;
});

@Component({
  selector: "ns-foo",
  template: `
    <BannerAd
      unitId="ca-app-pub-3940256099942544/6300978111"
      (layoutChanged)="bannerLoaded($event)"
    />
  `,
})
export class FooComponent {
  bannerLoaded(args: any) {
    const bannerView: BannerAd = args.object;
    bannerView.size = new BannerAdSize(320, 50);
    bannerView.load();
  }
}
TiagoLaraTecSys commented 3 days ago

@TiagoLaraTecSys I also encountered the same error. I hope this will be officially fixed.

As a workaround for now, I was able to display it correctly by writing it as follows:

import { Component } from "@angular/core";
import { registerElement } from "@nativescript/angular";
import { BannerAd, BannerAdSize } from "@nativescript/firebase-admob";

registerElement("BannerAd", () => {
  return require("@nativescript/firebase-admob").BannerAd;
});

@Component({
  selector: "ns-foo",
  template: `
    <BannerAd
      unitId="ca-app-pub-3940256099942544/6300978111"
      (layoutChanged)="bannerLoaded($event)"
    />
  `,
})
export class FooComponent {
  bannerLoaded(args: any) {
    const bannerView: BannerAd = args.object;
    bannerView.size = new BannerAdSize(320, 50);
    bannerView.load();
  }
}

Woww thnks maan i'm gonna try to do this