admob 与 nativescript-vue 集成
admob with nativescript-vue integration
我正在尝试使用 "nativescript-admob" 将 admob 添加到我的应用程序中,这是我现在拥有的代码:
<template>
<Page class="page">
<StackLayout class="hello-world">
<Label text="my home page"/>
</StackLayout>
</Page>
</template>
<script>
const admob = require("nativescript-admob");
export default {
mounted() {
admob.createBanner({
// if this 'view' property is not set, the banner is overlayed on the current top most view
// view: ..,
testing: true, // set to false to get real banners
size: admob.AD_SIZE.SMART_BANNER, // anything in admob.AD_SIZE, like admob.AD_SIZE.SMART_BANNER
androidBannerId: "ca-app-pub-AAAAAAAAAAA/AAAAAAAAA", // add your own
margins: {
// if both are set, top wins
//top: 10
bottom: 50
},
}).then(
function() {
console.log("admob createBanner done");
},
function(error) {
console.log("admob createBanner error: " + error);
}
)
},
}
</script>
我尝试在 "mounted" 上启动 admob 但我无法让它工作,有没有人以这种方式将 admob 与 nativescript-vue 集成?在我的情况下,我什至没有看到日志 "admob createBanner done" 日志,所以也许我没有很好地使用这个插件。
admob.createBanner() 函数必须被 setTimeout() 包围才能在之后启动,似乎它必须在页面完全加载时启动。感谢 slack nativescript-vue 频道贡献者的帮助!
我正在尝试使用 "nativescript-admob" 将 admob 添加到我的应用程序中,这是我现在拥有的代码:
<template>
<Page class="page">
<StackLayout class="hello-world">
<Label text="my home page"/>
</StackLayout>
</Page>
</template>
<script>
const admob = require("nativescript-admob");
export default {
mounted() {
admob.createBanner({
// if this 'view' property is not set, the banner is overlayed on the current top most view
// view: ..,
testing: true, // set to false to get real banners
size: admob.AD_SIZE.SMART_BANNER, // anything in admob.AD_SIZE, like admob.AD_SIZE.SMART_BANNER
androidBannerId: "ca-app-pub-AAAAAAAAAAA/AAAAAAAAA", // add your own
margins: {
// if both are set, top wins
//top: 10
bottom: 50
},
}).then(
function() {
console.log("admob createBanner done");
},
function(error) {
console.log("admob createBanner error: " + error);
}
)
},
}
</script>
我尝试在 "mounted" 上启动 admob 但我无法让它工作,有没有人以这种方式将 admob 与 nativescript-vue 集成?在我的情况下,我什至没有看到日志 "admob createBanner done" 日志,所以也许我没有很好地使用这个插件。
admob.createBanner() 函数必须被 setTimeout() 包围才能在之后启动,似乎它必须在页面完全加载时启动。感谢 slack nativescript-vue 频道贡献者的帮助!