-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21b1cf6
commit c19cb58
Showing
1 changed file
with
57 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |