From 4305a330423ff0a044016faac94ddbcc980a81f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A4=EB=B2=94=ED=83=9C?= Date: Fri, 1 Mar 2024 01:10:33 +0900 Subject: [PATCH] Fix: banner not disappear immediately after IAP purchased --- DiffuserStick/AppDelegate.swift | 4 ++++ .../ViewController/ActiveListViewController.swift | 10 ++++++++++ .../ViewController/ArchiveViewController.swift | 6 ++++++ .../ViewController/Setting/HelpViewController.swift | 2 +- .../Setting/SettingTableViewController.swift | 5 ++--- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/DiffuserStick/AppDelegate.swift b/DiffuserStick/AppDelegate.swift index 727941f..f4fc252 100755 --- a/DiffuserStick/AppDelegate.swift +++ b/DiffuserStick/AppDelegate.swift @@ -16,6 +16,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + + // // IAP Test only - Must be removed when distributing + // UserDefaults.standard.set(false, forKey: InAppProducts.productIDs[0]) + UNUserNotificationCenter.current().delegate = self // <- push 추가 GADMobileAds.sharedInstance().start(completionHandler: nil) // <- AdMob 초기화 return true diff --git a/DiffuserStick/ViewController/ActiveListViewController.swift b/DiffuserStick/ViewController/ActiveListViewController.swift index 027cfb9..813fbbe 100755 --- a/DiffuserStick/ViewController/ActiveListViewController.swift +++ b/DiffuserStick/ViewController/ActiveListViewController.swift @@ -65,6 +65,16 @@ class ActiveListViewController: UIViewController, AddDelegate { NotificationCenter.default.addObserver(self, selector: #selector(appOpened), name: UIApplication.didBecomeActiveNotification, object: nil) } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + if !AdManager.default.isReallyShowAd && bannerView != nil { + bannerView.removeFromSuperview() + // constraint 원상복구 + constraintBottom.constant = +50 + } + } + @objc func appClosed() { print("===== app closed =====") UserDefaults.standard.setValue(Date(), forKey: "last-closed-date") diff --git a/DiffuserStick/ViewController/ArchiveViewController.swift b/DiffuserStick/ViewController/ArchiveViewController.swift index d04b087..5f76eb9 100755 --- a/DiffuserStick/ViewController/ArchiveViewController.swift +++ b/DiffuserStick/ViewController/ArchiveViewController.swift @@ -59,6 +59,12 @@ class ArchiveViewController: UIViewController { print(error) } } + + if !AdManager.default.isReallyShowAd && bannerView != nil { + bannerView.removeFromSuperview() + // constraint 원상복구 + constraintBottom.constant = -50 + } } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { diff --git a/DiffuserStick/ViewController/Setting/HelpViewController.swift b/DiffuserStick/ViewController/Setting/HelpViewController.swift index 38c37d4..4ea8e28 100644 --- a/DiffuserStick/ViewController/Setting/HelpViewController.swift +++ b/DiffuserStick/ViewController/Setting/HelpViewController.swift @@ -75,7 +75,7 @@ extension HelpViewController: GADBannerViewDelegate { bannerView.rootViewController = self bannerView.load(GADRequest()) bannerView.delegate = self - cnstWebViewBottom.constant += adSize.size.height + cnstWebViewBottom.constant -= adSize.size.height } private func addBannerViewToView(_ bannerView: GADBannerView) { diff --git a/DiffuserStick/ViewController/Setting/SettingTableViewController.swift b/DiffuserStick/ViewController/Setting/SettingTableViewController.swift index e9bd73c..697a804 100644 --- a/DiffuserStick/ViewController/Setting/SettingTableViewController.swift +++ b/DiffuserStick/ViewController/Setting/SettingTableViewController.swift @@ -200,7 +200,6 @@ extension SettingTableViewController: GADBannerViewDelegate { bannerView.rootViewController = self bannerView.load(GADRequest()) bannerView.delegate = self - } private func addBannerViewToView(_ bannerView: GADBannerView) { @@ -301,10 +300,10 @@ extension SettingTableViewController { LoadingIndicatorUtil.default.hide(self) // 2. 세팅VC 광고 제거 (나머지 뷰는 다시 들어가면 제거되어 있음) - // removeBannerView() + bannerView.removeFromSuperview() // 3. 버튼 - // changePurchaseButtonStyle(isPurchased: true) + tableView.reloadData() } } }