Skip to content

Commit 2c926f4

Browse files
feat: add quiet hours for ads (Acode-Foundation#1779)
* feat: add quiet hours for ads * format * feat: reduce time range to 4am
1 parent 1207f64 commit 2c926f4

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/lib/startAd.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ export default async function startAd() {
2727

2828
await admob.start();
2929

30+
const currentHour = new Date().getHours();
31+
//currentHour >= 22: Covers 10:00 PM to 11:59 PM.
32+
//currentHour < 4: Covers 12:00 AM to 3:59 AM.
33+
const isQuietHours = currentHour >= 22 || currentHour < 4;
34+
35+
await admob.configure({
36+
appMuted: isQuietHours,
37+
appVolume: isQuietHours ? 0.0 : 1.0,
38+
});
39+
3040
const banner = new admob.BannerAd({
3141
adUnitId: adUnitIdBanner,
3242
position: "bottom",

0 commit comments

Comments
 (0)