- made theme 2 banner dynamic, if ad loads then only it will be shown

- made radio ad dynamic, now ad will show up only if ad is received
- added a retry count to fm, it will try 4 times to connect to the server if not then showing the reload btn
This commit is contained in:
Bilal
2024-09-19 01:22:04 +05:30
parent 3a499281c2
commit dcbbfc3417
11 changed files with 306 additions and 172 deletions

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
@@ -961,7 +961,7 @@
<rect key="frame" x="0.0" y="348" width="414" height="514"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="1iA-oh-toI">
<rect key="frame" x="0.0" y="0.0" width="414" height="578"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="448"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Explore WOKA" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cla-Q5-K2m" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="394" height="24"/>
@@ -983,12 +983,9 @@
</collectionViewFlowLayout>
<cells/>
</collectionView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qyf-6K-qmR" customClass="GADBannerView">
<rect key="frame" x="10" y="194" width="394" height="120"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" constant="120" id="N13-hk-WFw"/>
</constraints>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qyf-6K-qmR">
<rect key="frame" x="10" y="189" width="394" height="120"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<integer key="value" value="5"/>
@@ -996,7 +993,7 @@
</userDefinedRuntimeAttributes>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="02e-rk-u9Q">
<rect key="frame" x="10" y="324" width="394" height="224"/>
<rect key="frame" x="10" y="194" width="394" height="224"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Coming Soon on WOKA" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vdt-pC-uNJ" customClass="LocalisedElementsLabel" customModule="WOKA" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="374" height="24"/>
@@ -1070,7 +1067,7 @@
<edgeInsets key="layoutMargins" top="10" left="10" bottom="0.0" right="10"/>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="K3K-3D-e9X">
<rect key="frame" x="10" y="558" width="394" height="20"/>
<rect key="frame" x="10" y="428" width="394" height="20"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="Etm-uk-Fs9"/>
@@ -1098,6 +1095,7 @@
<constraint firstItem="QRd-bR-MwE" firstAttribute="bottom" secondItem="wIw-DO-ba0" secondAttribute="bottom" id="8aT-sg-dlZ"/>
<constraint firstItem="wIw-DO-ba0" firstAttribute="top" secondItem="Ksi-1c-xBG" secondAttribute="bottom" constant="5" id="9iK-1y-iUL"/>
<constraint firstItem="wIw-DO-ba0" firstAttribute="trailing" secondItem="QRd-bR-MwE" secondAttribute="trailing" id="B2f-vS-BlM"/>
<constraint firstItem="Qyf-6K-qmR" firstAttribute="height" secondItem="Y2R-2G-NBv" secondAttribute="height" multiplier="0.133929" id="DLo-Fr-AKa"/>
<constraint firstItem="03W-c9-Rk6" firstAttribute="top" secondItem="Ksi-1c-xBG" secondAttribute="top" id="Lbz-Fr-iIx"/>
<constraint firstAttribute="bottom" secondItem="1fD-0F-KMn" secondAttribute="bottom" constant="-70" id="Prn-39-0xD"/>
<constraint firstItem="dUF-uY-OBL" firstAttribute="centerY" secondItem="wHk-XC-Cqq" secondAttribute="centerY" id="VXh-QC-K3B"/>
@@ -1115,13 +1113,13 @@
</constraints>
</view>
<connections>
<outlet property="adView" destination="Qyf-6K-qmR" id="bRN-Dk-4ja"/>
<outlet property="avatarImage" destination="4xI-oX-ffb" id="CJN-fs-BUe"/>
<outlet property="collectionView" destination="4rq-xX-XRh" id="Z66-JF-bp2"/>
<outlet property="liveTVActivityIndicator" destination="3yT-Xz-Xmu" id="qBm-dV-10P"/>
<outlet property="liveTvView" destination="Ksi-1c-xBG" id="xcg-na-dB1"/>
<outlet property="nameLabel" destination="Qn2-Bb-Ud6" id="t3V-Kr-Tkh"/>
<outlet property="notificationBtn" destination="tl8-VA-AjQ" id="p7t-q6-5US"/>
<outlet property="testAdView" destination="Qyf-6K-qmR" id="rRh-Pk-nGq"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AKa-H1-a6U" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

View File

@@ -20,7 +20,7 @@ class ThemeTwoVC: UIViewController{
@IBOutlet weak var notificationBtn: UIButton!
@IBOutlet weak var liveTVActivityIndicator: UIActivityIndicatorView!
@IBOutlet weak var testAdView: GADBannerView!
@IBOutlet weak var adView: UIView!
var vm = ThemeTwoVM()
@@ -55,13 +55,6 @@ class ThemeTwoVC: UIViewController{
if MyListDataTemp.shareInstance.favListingData?.showData == nil {
MyListDataTemp.shareInstance.favListingData = FavouriteListingDM.ResultData(totalRecords: nil, showData: FavouriteListingDM.ResultData.ShowData(hindi: [],english: []),videoData: [],gameData: [],singKaraokeData: [],audioData: [])
}
/*
This is test ad.
*/
testAdView.adUnitID = K.GoogleAdIDs.themeTwo
testAdView.rootViewController = self
testAdView.load(GADRequest())
}
override func viewWillAppear(_ animated: Bool) {
@@ -274,3 +267,41 @@ extension ThemeTwoVC : UICollectionViewDelegateFlowLayout{
}
// MARK: - Google Ad Banner Delegate
extension ThemeTwoVC : GADBannerViewDelegate{
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
print("bannerViewDidReceiveAd")
adView.isHidden = false
bannerView.backgroundColor = #colorLiteral(red: 0.01960784314, green: 0, blue: 0.2196078431, alpha: 1)
bannerView.alpha = 0
UIView.animate(withDuration: 0.3, animations: {
bannerView.alpha = 1
})
}
func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
self.adView.isHidden = true
print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
func bannerViewDidRecordImpression(_ bannerView: GADBannerView) {
print("bannerViewDidRecordImpression")
}
func bannerViewWillPresentScreen(_ bannerView: GADBannerView) {
print("bannerViewWillPresentScreen")
}
func bannerViewDidRecordClick(_ bannerView: GADBannerView) {
print("bannerViewDidRecordClick")
}
func bannerViewWillDismissScreen(_ bannerView: GADBannerView) {
print("bannerViewWillDIsmissScreen")
}
func bannerViewDidDismissScreen(_ bannerView: GADBannerView) {
print("bannerViewDidDismissScreen")
}
}

View File

@@ -9,6 +9,7 @@ import UIKit
import AVFoundation
import JWPlayerKit
import Alamofire
import GoogleMobileAds
struct Theme2Struct{
let imageName : String
@@ -27,6 +28,7 @@ class ThemeTwoVM{
let monitor = NWPathMonitor()
let queue = DispatchQueue.global(qos: .background)
var isNetworkMonitored = false
var bannerView = GADBannerView()
/*
Static cell data
@@ -50,6 +52,12 @@ class ThemeTwoVM{
guard let self else{return}
self.playLiveTV()
}
// configuring the google ads.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { [weak self] in
guard let self else{return}
AdReusable.sharedInstance.setupBannerAd(bannerView: bannerView, in: vc.adView, adUnitID: K.GoogleAdIDs.splashBanner1, viewController: self.vc, height: 8, width: 15)
})
}
private func handleNotificationCenter(){
@@ -58,7 +66,6 @@ class ThemeTwoVM{
NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.viewPush(notification:)), name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeTwoPush), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleRouteChange(_:)), name: AVAudioSession.routeChangeNotification, object: nil)
}
// MARK: - This will handle all clicks for modules