Skip to content

Commit ce15ea1

Browse files
feat: add quiet hours for ads
1 parent 1207f64 commit ce15ea1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib/startAd.js

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

2828
await admob.start();
2929

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

0 commit comments

Comments
 (0)