如何在nativescript,angular 2和打字稿中使用admob [英] How can use admob in nativescript , angular 2 and typescript

查看:78
本文介绍了如何在nativescript,angular 2和打字稿中使用admob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys

我是Nativescript中的新手并尝试使用admob

我使用带有angular2和typescript的nativescript

但没有任何使用admob by angular2和打字稿的例子



这是我的代码





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


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);





但我有错误无法找到模块nativescript-admob



我尝试过:



我正在尝试解决它,但我没有成功,所以我需要帮助



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

推荐答案

你使用
$ b安装了插件吗? $ b

Did you install the plugin using

tns plugin add nativescript-admob





如果问题仍然存在也可以尝试将插件类型定义(它们带有插件)添加到references.d.ts





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


这篇关于如何在nativescript,angular 2和打字稿中使用admob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆