콘텐츠 상세 - 배너 광고 추가

This commit is contained in:
Yu Sung
2023-09-14 12:16:01 +09:00
parent 48b1093dac
commit b2f0975ad1
9 changed files with 577 additions and 66 deletions

View File

@@ -0,0 +1,33 @@
//
// BannerAdView.swift
// SodaLive
//
// Created by klaus on 2023/09/14.
//
import SwiftUI
import UIKit
import GoogleMobileAds
struct BannerAdView: UIViewControllerRepresentable {
let adUnitId: String
func makeUIViewController(context: Context) -> some UIViewController {
let viewController = UIViewController()
let bannerSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(UIScreen.main.bounds.width)
let banner = GADBannerView(adSize: bannerSize)
banner.rootViewController = viewController
viewController.view.addSubview(banner)
viewController.view.frame = CGRect(origin: .zero, size: bannerSize.size)
banner.adUnitID = adUnitId
banner.load(GADRequest())
return viewController
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}

View File

@@ -9,6 +9,7 @@ import UIKit
import FirebaseCore
import FirebaseMessaging
import GoogleMobileAds
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -16,6 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
GADMobileAds.sharedInstance().start()
Messaging.messaging().delegate = self

View File

@@ -7,6 +7,7 @@
import SwiftUI
import Kingfisher
import GoogleMobileAds
import RefreshableScrollView
struct ContentDetailView: View {
@@ -66,56 +67,65 @@ struct ContentDetailView: View {
viewModel.getAudioContentDetail()
}) {
VStack(spacing: 0) {
LazyVStack(spacing: 0) {
ContentDetailPlayView(
audioContent: audioContent,
isShowPreviewAlert: $viewModel.isShowPreviewAlert
)
ContentDetailInfoView(
isExpandDescription: $viewModel.isExpandDescription,
isShowPreviewAlert: $viewModel.isShowPreviewAlert,
audioContent: audioContent,
onClickLike: { viewModel.likeContent() },
onClickShare: {
viewModel.shareAudioContent(
contentImage: audioContent.coverImageUrl,
contentTitle: "\(audioContent.title) - \(audioContent.creator.nickname)"
)
},
onClickDonation: { viewModel.isShowDonationPopup = true }
)
if audioContent.price > 0 &&
!audioContent.existOrdered &&
audioContent.orderType == nil &&
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
ContentDetailPurchaseButton(price: audioContent.price)
.contentShape(Rectangle())
.onTapGesture { isShowOrderView = true }
}
if audioContent.isCommentAvailable {
ContentDetailCommentView(
commentCount: audioContent.commentCount,
commentList: audioContent.commentList,
registerComment: { comment in
self.viewModel.registerComment(comment: comment)
}
ContentDetailPlayView(
audioContent: audioContent,
isShowPreviewAlert: $viewModel.isShowPreviewAlert
)
if audioContent.price <= 0 || (audioContent.price > 0 && !audioContent.existOrdered) {
BannerAdView(adUnitId: FREE_CONTENT_BANNER_AD_UNIT_ID)
.frame(
width: screenSize().width,
height: GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(screenSize().width).size.height
)
.padding(10.3)
.background(Color.white.opacity(0.1))
.cornerRadius(5.3)
.padding(.top, 13.3)
}
ContentDetailInfoView(
isExpandDescription: $viewModel.isExpandDescription,
isShowPreviewAlert: $viewModel.isShowPreviewAlert,
audioContent: audioContent,
onClickLike: { viewModel.likeContent() },
onClickShare: {
viewModel.shareAudioContent(
contentImage: audioContent.coverImageUrl,
contentTitle: "\(audioContent.title) - \(audioContent.creator.nickname)"
)
},
onClickDonation: { viewModel.isShowDonationPopup = true }
)
.padding(.horizontal, 13.3)
if audioContent.price > 0 &&
!audioContent.existOrdered &&
audioContent.orderType == nil &&
audioContent.creator.creatorId != UserDefaults.int(forKey: .userId) {
ContentDetailPurchaseButton(price: audioContent.price)
.contentShape(Rectangle())
.onTapGesture {
if audioContent.commentCount > 0 {
isShowCommentListView = true
}
.padding(.horizontal, 13.3)
.onTapGesture { isShowOrderView = true }
}
if audioContent.isCommentAvailable {
ContentDetailCommentView(
commentCount: audioContent.commentCount,
commentList: audioContent.commentList,
registerComment: { comment in
self.viewModel.registerComment(comment: comment)
}
)
.padding(10.3)
.background(Color.white.opacity(0.1))
.cornerRadius(5.3)
.padding(.top, 13.3)
.contentShape(Rectangle())
.padding(.horizontal, 13.3)
.onTapGesture {
if audioContent.commentCount > 0 {
isShowCommentListView = true
}
}
}
.padding(.horizontal, 13.3)
Rectangle()
.foregroundColor(Color(hex: "232323"))

View File

@@ -14,3 +14,4 @@ let AGORA_APP_ID = "b96574e191a9430fa54c605528aa3ef7"
let AGORA_APP_CERTIFICATE = "ae18ade3afcf4086bd4397726eb0654c"
let BOOTPAY_APP_ID = "6242a7772701800023f68b2f"
let FREE_CONTENT_BANNER_AD_UNIT_ID = "ca-app-pub-3940256099942544/2934735716"

View File

@@ -14,3 +14,4 @@ let AGORA_APP_ID = "e34e40046e9847baba3adfe2b8ffb4f6"
let AGORA_APP_CERTIFICATE = "15cadeea4ba94ff7b091c9a10f4bf4a6"
let BOOTPAY_APP_ID = "64c35be1d25985001dc50c88"
let FREE_CONTENT_BANNER_AD_UNIT_ID = "ca-app-pub-1299501215847962/7126167277"