Skip to content

Commit

Permalink
Fixed: Setting an upper age limit for ad content, reducing the freque…
Browse files Browse the repository at this point in the history
…ncy of ad appearances, etc.
  • Loading branch information
ayaysir committed Mar 4, 2024
1 parent d7cf774 commit 96d2267
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 1 deletion.
3 changes: 3 additions & 0 deletions MusicBox/Main/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
Database.database().isPersistenceEnabled = false
GADMobileAds.sharedInstance().start(completionHandler: nil)

// 광고 최대 연령 조정
GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating = .teen

// 앱을 출시하기 전에 이러한 테스트 기기를 설정하는 코드를 반드시 삭제하세요.
// GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = ["2077ef9a63d2b398840261c8221a0c9b"]

Expand Down
2 changes: 1 addition & 1 deletion MusicBox/ViewController/FileCollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class FileCollectionViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()

prepareAndShowFullScreenAd()
// prepareAndShowFullScreenAd()
askPhotoAuth()

setMenuDropDown()
Expand Down
29 changes: 29 additions & 0 deletions MusicBox/ViewController/MusicPaperViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,35 @@ extension MusicPaperViewController: GADFullScreenContentDelegate {
}

let request = GADRequest()
request.keywords = [
"음악",
"악기",
"Music",
"instrument",
"score",
"sheet",
"piano",
"roll",
"노래",
"song",
"classical",
"클래식",
"유아",
"청소년",
"학습",
"공부",
"musical",
"연주",
"performance",
"칼림바",
"kalimba",
"커뮤니티",
"온라인",
"트럼펫",
"학원",
"academy"
]

GADInterstitialAd.load(withAdUnitID: AdInfo.shared.paperFullScreen,
request: request,
completionHandler: { [self] ad, error in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import GoogleMobileAds
import Lottie

class PostViewController: UIViewController {
private var interstitial: GADInterstitialAd?

lazy var lottieView: LottieAnimationView = {
let animationView = LottieAnimationView(name: "129574-ginger-bread-socks-christmas")
Expand Down Expand Up @@ -149,6 +150,8 @@ class PostViewController: UIViewController {
}

SwiftSpinner.hide()

prepareFullScreenAd()
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -176,6 +179,12 @@ class PostViewController: UIViewController {
bannerView?.fitInView(self)
}

override func willMove(toParent parent: UIViewController?) {
if AdManager.isReallyShowAd, let interstitial {
interstitial.present(fromRootViewController: self)
}
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "UpdatePostSegue" {
let updateVC = segue.destination as? UpdatePostViewController
Expand Down Expand Up @@ -379,3 +388,55 @@ extension PostViewController: GADBannerViewDelegate {
}
}
}

extension PostViewController: GADFullScreenContentDelegate {
/// 전면 광고 준비
func prepareFullScreenAd() {
guard AdManager.isReallyShowAd else {
return
}

let request = GADRequest()
request.keywords = [
"음악",
"악기",
"Music",
"instrument",
"score",
"sheet",
"piano",
"roll",
"노래",
"song",
"classical",
"클래식",
"유아",
"청소년",
"학습",
"공부",
"musical",
"연주",
"performance",
"칼림바",
"kalimba",
"커뮤니티",
"온라인",
"트럼펫",
"학원",
"academy"
]

GADInterstitialAd.load(withAdUnitID: AdInfo.shared.paperFullScreen,
request: request,
completionHandler: { [self] ad, error in
if let error = error {
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
return
}

interstitial = ad
interstitial?.fullScreenContentDelegate = self
}
)
}
}

0 comments on commit 96d2267

Please sign in to comment.