Nativescript Firebase插件有Admob,您可以使用智能横幅,但我们不能检测横幅的高度。在不同屏幕大小上加载横幅后,我能得到谁的横幅高度?
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: 10,
top: -1
},
androidBannerId: "ca-app-pub-9517346003011652/7749101329",
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
],
keywords: ["keyword1", "keyword2"], // add keywords for ad targeting
onOpened: () => console.log("Ad opened"),
onClicked: () => console.log("Ad clicked"),
onLeftApplication: () => console.log("Ad left application")
}).then(
function () {
console.log("AdMob banner showing");
},
function (errorMessage) {
dialogs.alert({
title: "AdMob error",
message: errorMessage,
okButtonText: "Hmmkay"
});
}
);发布于 2020-07-22 16:26:11
,我们先得到屏幕大小,然后用SMART_BANNER逻辑进行计算。
导入这个平台
const platform = require("platform") 高度除以比例
const screenHeightDp =platform.screen.mainScreen.heightPixels / platform.screen.mainScreen.scale;将计算作为智能横幅工作。
const BannerHeight = screenHeightDp > 720 ? 90 : screenHeightDp > 400 ? 50 : 32;这是我们的旗帜高度
console.log(BannerHeight); https://stackoverflow.com/questions/63038889
复制相似问题