Skip to content

Commit

Permalink
update www/src/plugins/admob.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianjnuwu committed Jan 6, 2025
1 parent 21b1cf6 commit c19cb58
Showing 1 changed file with 57 additions and 61 deletions.
118 changes: 57 additions & 61 deletions www/src/plugins/admob.ts
Original file line number Diff line number Diff line change
@@ -1,85 +1,81 @@
import {
AdMob,
BannerAdSize,
BannerAdPosition,
AdMob,
BannerAdSize,
BannerAdPosition
} from "@capacitor-community/admob";
import $ from "jquery";

function $show_banner() {
AdMob.showBanner({
adId: "ca-app-pub-6690516270288705/1043067086",
adSize: BannerAdSize.FULL_BANNER,
position: BannerAdPosition.BOTTOM_CENTER,
margin: 0,
// isTesting: true
// npa: true
})
.then(() => {
return console.log("Banner displayed.");
AdMob.showBanner({
adId: "ca-app-pub-6690516270288705/1043067086",
adSize: BannerAdSize.FULL_BANNER,
position: BannerAdPosition.BOTTOM_CENTER,
margin: 0
// isTesting: true
// npa: true
})
.catch((err) => {
return console.log("Error displaying banner: ", err.message);
});
.then(() => {
return console.log("Banner displayed.");
})
.catch(err => {
return console.log("Error displaying banner: ", err.message);
});
}

function $hide_banner() {
AdMob.hideBanner()
.then(() => {
return console.log("Banner hidden successfully.");
})
.catch((err) => {
return console.log("Error hiding banner: ", err.message);
});
AdMob.hideBanner()
.then(() => {
return console.log("Banner hidden successfully.");
})
.catch(err => {
return console.log("Error hiding banner: ", err.message);
});
}

function $show_video() {
const adId = "ca-app-pub-6690516270288705/7898187843";
AdMob.prepareRewardVideoAd({ adId })
.then(() => {
console.log("Rewarded interstitial prepared.");
return AdMob.showRewardVideoAd();
})
.then(() => {
console.log("Rewarded interstitial displayed successfully.");
})
.catch((err) => {
console.log("Error displaying rewarded interstitial: ", err.message);
});
const adId = "ca-app-pub-6690516270288705/7898187843";
AdMob.prepareRewardVideoAd({ adId })
.then(() => {
console.log("Rewarded interstitial prepared.");
return AdMob.showRewardVideoAd();
})
.then(() => {
console.log("Rewarded interstitial displayed successfully.");
})
.catch(err => {
console.log(
"Error displaying rewarded interstitial: ",
err.message
);
});
}

function $award() {
AdMob.prepareInterstitial({
adId: "ca-app-pub-6690516270288705/8937605645",
})
.then(() => {
console.log("Interstitial prepared.");

return AdMob.showInterstitial();
})
.then(() => {
console.log("Interstitial ad displayed successfully.");
AdMob.prepareInterstitial({
adId: "ca-app-pub-6690516270288705/8937605645"
})
.catch((err) => {
console.log("Error displaying interstitial ad: ", err.message);
});
}
.then(() => {
console.log("Interstitial prepared.");

if (window.Capacitor.getPlatform() !== "android") {
console.log(
`AdMob: Unsupported platform (${window.Capacitor.getPlatform()})`,
);
return;
}
return AdMob.showInterstitial();
})
.then(() => {
console.log("Interstitial ad displayed successfully.");
})
.catch(err => {
console.log("Error displaying interstitial ad: ", err.message);
});
}

AdMob.initialize()
AdMob.initialize()
.then(() => {
console.log("AdMob initialized.");
console.log("AdMob initialized.");
})
.catch((err) => {
console.log("Error initializing AdMob: ", err.message);
.catch(err => {
console.log("Error initializing AdMob: ", err.message);
});

$("#form_button").on("click", () => {
$("#form_button").on("click", () => {
$show_banner();
$show_video();
});
});

0 comments on commit c19cb58

Please sign in to comment.