Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys
I'm a new in Nativescript and trying to use admob
I'm using nativescript with angular2 and typescript
but not there any example using admob by angular2 and typescript

this is my code


JavaScript
import { platformNativeScriptDynamic, NativeScriptModule } from "nativescript-angular/platform";
import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { admobModule } from "nativescript-admob";

@NgModule({
    declarations: [AppComponent],
    bootstrap: [AppComponent],
    imports: [NativeScriptModule],
})
class AppComponentModule {
    function createBanner() {
        admobModule.createBanner({
        testing: true,
        size: admobModule.AD_SIZE.SMART_BANNER,
        androidBannerId: "ca-app-pub-4225186613160852/8357139706",
        margins: {
            bottom: 0
        }
    }).then(function() {
        console.log("admob createBanner done");
    }, function(error) {
        console.log("admob createBanner error: " + error);
    });
    }

    function createInterstitial(){
         admobModule.createInterstitial({
        testing: true,
        androidInterstitialId: "ca-app-pub-4225186613160852/7938337306",
    }).then(function() {
        console.log("admob createInterstitial done");
    }, function(error) {
        console.log("admob createInterstitial error: " + error);
    });
    }

    function hideBanner () {
    admobModule.hideBanner().then(function() {
        console.log("admob hideBanner done");
    }, function(error) {
        console.log("admob hideBanner error: " + error);
    });
}
}

platformNativeScriptDynamic().bootstrapModule(AppComponentModule);


but i have error Cannot find module nativescript-admob

What I have tried:

i'm trying to fix it but i'm not success so i need help
Posted
Updated 21-Nov-16 15:54pm

1 solution

Did you install the plugin using

tns plugin add nativescript-admob


If your problem continues you can also try to add the plugin type definitions(they come with plugin) to references.d.ts

/// <reference path="./node_modules/nativescript-admob/admob.d.ts"></reference>


I hope your problem is solved
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900