- added ads
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import GoogleMobileAds
|
||||
|
||||
class GamesListVC: UIViewController {
|
||||
|
||||
@@ -25,6 +26,9 @@ class GamesListVC: UIViewController {
|
||||
|
||||
var vm = GamesListVM()
|
||||
|
||||
private var interstitial: GADInterstitialAd?
|
||||
private var rewardedAd: GADRewardedAd?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
vm.vc = self
|
||||
@@ -33,6 +37,22 @@ class GamesListVC: UIViewController {
|
||||
self.title = "GAMES".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
|
||||
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
|
||||
navigationController?.navigationBar.shadowImage = UIImage()
|
||||
|
||||
Task {
|
||||
do {
|
||||
interstitial = try await GADInterstitialAd.load(
|
||||
withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: GADRequest())
|
||||
interstitial?.fullScreenContentDelegate = self
|
||||
|
||||
rewardedAd = try await GADRewardedAd.load(
|
||||
withAdUnitID: "ca-app-pub-3940256099942544/1712485313", request: GADRequest())
|
||||
rewardedAd?.fullScreenContentDelegate = self
|
||||
|
||||
|
||||
} catch {
|
||||
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -150,9 +170,35 @@ extension GamesListVC : TableViewSRC{
|
||||
vm.setHeaderData()
|
||||
|
||||
let data = vm.gameData[indexPath.row]
|
||||
|
||||
if let postID = data.id{
|
||||
PersistentStorage.shared.addGamesCount(postID: postID)
|
||||
}
|
||||
|
||||
/*
|
||||
This is only for test
|
||||
*/
|
||||
if data.title == "WOKA Ludo"{
|
||||
// guard let interstitial = interstitial else {
|
||||
// return print("Ad wasn't ready.")
|
||||
// }
|
||||
//
|
||||
// // The UIViewController parameter is an optional.
|
||||
// interstitial.present(fromRootViewController: nil)
|
||||
guard let rewardedAd = rewardedAd else {
|
||||
return print("Ad wasn't ready.")
|
||||
}
|
||||
|
||||
// The UIViewController parameter is an optional.
|
||||
rewardedAd.present(fromRootViewController: nil) {
|
||||
let reward = rewardedAd.adReward
|
||||
print("Reward received with currency \(reward.amount), amount \(reward.amount.doubleValue)")
|
||||
// TODO: Reward the user.
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.Games, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Games.gamesDetailVC) as! GamesDetailVC
|
||||
vcPush.modalPresentationStyle = .overCurrentContext
|
||||
@@ -225,3 +271,45 @@ extension GamesListVC: UIScrollViewDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension GamesListVC : GADFullScreenContentDelegate{
|
||||
/// Tells the delegate that the ad failed to present full screen content.
|
||||
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
|
||||
print("Ad did fail to present full screen content.")
|
||||
}
|
||||
|
||||
/// Tells the delegate that the ad will present full screen content.
|
||||
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
|
||||
print("Ad will present full screen content.")
|
||||
}
|
||||
|
||||
/// Tells the delegate that the ad dismissed full screen content.
|
||||
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
|
||||
print("Ad did dismiss full screen content.")
|
||||
let data = vm.gameData.first
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.Games, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Games.gamesDetailVC) as! GamesDetailVC
|
||||
vcPush.modalPresentationStyle = .overCurrentContext
|
||||
vcPush.modalTransitionStyle = .crossDissolve
|
||||
vcPush.gameIndex = 0
|
||||
vcPush.gameData = data
|
||||
vcPush.delegate = self
|
||||
self.present(vcPush, animated: true)
|
||||
|
||||
Task {
|
||||
do {
|
||||
interstitial = try await GADInterstitialAd.load(
|
||||
withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: GADRequest())
|
||||
interstitial?.fullScreenContentDelegate = self
|
||||
|
||||
rewardedAd = try await GADRewardedAd.load(
|
||||
withAdUnitID: "ca-app-pub-3940256099942544/1712485313", request: GADRequest())
|
||||
rewardedAd?.fullScreenContentDelegate = self
|
||||
} catch {
|
||||
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>GADApplicationIdentifier</key>
|
||||
<string>ca-app-pub-5699008063638916~6654980943</string>
|
||||
<key>API_KEY_ID</key>
|
||||
<string>$(API_KEY_ID)</string>
|
||||
<key>API_KEY_PASS</key>
|
||||
|
||||
@@ -10,6 +10,7 @@ import Lottie
|
||||
import IQKeyboardManagerSwift
|
||||
import JWPlayerKit
|
||||
import Firebase
|
||||
import GoogleMobileAds
|
||||
import OneSignalFramework
|
||||
|
||||
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
||||
@@ -32,10 +33,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
//
|
||||
//Initialize Firebase
|
||||
FirebaseApp.configure()
|
||||
|
||||
// Initialize the Google Mobile Ads SDK.
|
||||
GADMobileAds.sharedInstance().start(completionHandler: nil)
|
||||
|
||||
// enabling the IQKeyboard manager instance
|
||||
IQKeyboardManager.shared.enable = true
|
||||
IQKeyboardManager.shared.resignOnTouchOutside = true
|
||||
|
||||
@@ -14,7 +14,7 @@ class NetworkManager{
|
||||
|
||||
private init() {}
|
||||
|
||||
enum APIError: Error {
|
||||
enum APIError: Error, LocalizedError {
|
||||
case networkError
|
||||
case noNetwork(message:String)
|
||||
case invalidURL
|
||||
@@ -22,6 +22,25 @@ class NetworkManager{
|
||||
case responseValidationFailed
|
||||
case unknown(message: String)
|
||||
case custom(message: String)
|
||||
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .networkError:
|
||||
return "A network error occurred."
|
||||
case .noNetwork(let message):
|
||||
return "No network: \(message)"
|
||||
case .invalidURL:
|
||||
return "The URL provided is invalid."
|
||||
case .parameterEncodingFailed:
|
||||
return "Failed to encode the parameters."
|
||||
case .responseValidationFailed:
|
||||
return "Response validation failed."
|
||||
case .unknown(let message):
|
||||
return "Unknown error: \(message)"
|
||||
case .custom(let message):
|
||||
return "Custom error: \(message)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This function will do the network call for HTTPMethod & Encoding is URLEncoding with contentType ["application/json"]
|
||||
|
||||
@@ -108,27 +108,36 @@ extension ShopListingVC : TableViewSRC{
|
||||
|
||||
if vm.superCatData.count == 0 {return}
|
||||
|
||||
if let adsData = AuthFunc.shareInstance.adsData, (adsData.result?.filter({$0.forPage == AdsEnum.shop_super_category.rawValue}).first) != nil{
|
||||
// check if ads data contains ad for webseries
|
||||
let superCatID = vm.superCatData[indexPath.row - 1].id
|
||||
if let superCatID{
|
||||
PersistentStorage.shared.addShopCount(postID: superCatID)
|
||||
}
|
||||
let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopCategoryVC) as! ShopCategoryVC
|
||||
vcPush.vm.superCatID = superCatID
|
||||
self.navigationController?.pushViewController(vcPush, animated: true)
|
||||
return
|
||||
}else{
|
||||
let superCatID = vm.superCatData[indexPath.row].id
|
||||
if let superCatID{
|
||||
PersistentStorage.shared.addShopCount(postID: superCatID)
|
||||
}
|
||||
let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopCategoryVC) as! ShopCategoryVC
|
||||
vcPush.vm.superCatID = superCatID
|
||||
self.navigationController?.pushViewController(vcPush, animated: true)
|
||||
let superCatID = vm.superCatData[indexPath.row].id
|
||||
if let superCatID{
|
||||
PersistentStorage.shared.addShopCount(postID: superCatID)
|
||||
}
|
||||
let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopCategoryVC) as! ShopCategoryVC
|
||||
vcPush.vm.superCatID = superCatID
|
||||
self.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
// if let adsData = AuthFunc.shareInstance.adsData, (adsData.result?.filter({$0.forPage == AdsEnum.shop_super_category.rawValue}).first) != nil{
|
||||
// // check if ads data contains ad for webseries
|
||||
// let superCatID = vm.superCatData[indexPath.row - 1].id
|
||||
// if let superCatID{
|
||||
// PersistentStorage.shared.addShopCount(postID: superCatID)
|
||||
// }
|
||||
// let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
|
||||
// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopCategoryVC) as! ShopCategoryVC
|
||||
// vcPush.vm.superCatID = superCatID
|
||||
// self.navigationController?.pushViewController(vcPush, animated: true)
|
||||
// return
|
||||
// }else{
|
||||
// let superCatID = vm.superCatData[indexPath.row].id
|
||||
// if let superCatID{
|
||||
// PersistentStorage.shared.addShopCount(postID: superCatID)
|
||||
// }
|
||||
// let sb = UIStoryboard(name: K.StoryBoard.shop, bundle: nil)
|
||||
// let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Shop.shopCategoryVC) as! ShopCategoryVC
|
||||
// vcPush.vm.superCatID = superCatID
|
||||
// self.navigationController?.pushViewController(vcPush, animated: true)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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="448"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="578"/>
|
||||
<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,8 +983,20 @@
|
||||
</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>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
|
||||
<integer key="value" value="5"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="02e-rk-u9Q">
|
||||
<rect key="frame" x="10" y="194" width="394" height="224"/>
|
||||
<rect key="frame" x="10" y="324" 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"/>
|
||||
@@ -1058,7 +1070,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="428" width="394" height="20"/>
|
||||
<rect key="frame" x="10" y="558" 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"/>
|
||||
@@ -1109,6 +1121,7 @@
|
||||
<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"/>
|
||||
@@ -1413,7 +1426,7 @@
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBrownColor">
|
||||
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
import UIKit
|
||||
import AVFAudio
|
||||
import AVFoundation
|
||||
import GoogleMobileAds
|
||||
|
||||
class ThemeTwoVC: UIViewController {
|
||||
class ThemeTwoVC: UIViewController{
|
||||
|
||||
weak var delegate: ChildViewControllerDelegate?
|
||||
@IBOutlet weak var collectionView: UICollectionView!
|
||||
@@ -19,9 +20,11 @@ class ThemeTwoVC: UIViewController {
|
||||
@IBOutlet weak var notificationBtn: UIButton!
|
||||
|
||||
@IBOutlet weak var liveTVActivityIndicator: UIActivityIndicatorView!
|
||||
@IBOutlet weak var testAdView: GADBannerView!
|
||||
|
||||
var vm = ThemeTwoVM()
|
||||
|
||||
|
||||
deinit{
|
||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.reloadTheme), object: nil)
|
||||
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: K.NotificationCenterReloads.themeTwoPush), object: nil)
|
||||
@@ -53,6 +56,15 @@ 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 = "ca-app-pub-3940256099942544/2934735716"
|
||||
testAdView.rootViewController = self
|
||||
testAdView.load(GADRequest())
|
||||
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -260,3 +272,5 @@ extension ThemeTwoVC : UICollectionViewDelegateFlowLayout{
|
||||
// return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class WebSeriesVM{
|
||||
// Calculate the new view height based on the multiplier
|
||||
// maxHeaderHeight = currentScreenHeight * heightMultiplier
|
||||
|
||||
//Set banner height
|
||||
//Set Header height
|
||||
maxHeaderHeight = UIScreen.main.bounds.width * 0.55
|
||||
vc.headerHeight.constant = maxHeaderHeight
|
||||
|
||||
|
||||
Reference in New Issue
Block a user