-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEATURE] 링크 AI 요약 시 Google Ads 전면 광고 연결
- Loading branch information
Showing
32 changed files
with
325 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
Projects/Core/Services/Sources/ATTrackingManager/ATTrackingManagerClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// ATTTrackingManagerClient.swift | ||
// Services | ||
// | ||
// Created by kyuchul on 11/30/24. | ||
// Copyright © 2024 com.kyuchul.blink. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import AppTrackingTransparency | ||
|
||
import Dependencies | ||
import DependenciesMacros | ||
|
||
@DependencyClient | ||
public struct ATTrackingManagerClient { | ||
public var requestTrackingAuthorization: @Sendable () async -> Void | ||
} | ||
|
||
extension ATTrackingManagerClient: DependencyKey { | ||
public static var liveValue: ATTrackingManagerClient = live() | ||
private static func live() -> ATTrackingManagerClient { | ||
|
||
return ATTrackingManagerClient( | ||
requestTrackingAuthorization: { @MainActor in | ||
return await withCheckedContinuation { continuation in | ||
ATTrackingManager.requestTrackingAuthorization { _ in | ||
continuation.resume() | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// GoogleAdsClient.swift | ||
// Services | ||
// | ||
// Created by kyuchul on 11/30/24. | ||
// Copyright © 2024 com.kyuchul.blink. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import GoogleMobileAds | ||
|
||
import Dependencies | ||
import DependenciesMacros | ||
|
||
@DependencyClient | ||
public struct GoogleMobileAdsClient { | ||
public var start: @Sendable () async -> Void | ||
public var load: @Sendable () async throws -> GoogleAd | ||
} | ||
|
||
extension GoogleMobileAdsClient: DependencyKey { | ||
public static var liveValue: GoogleMobileAdsClient = live() | ||
private static func live() -> GoogleMobileAdsClient { | ||
return GoogleMobileAdsClient( | ||
start: { | ||
await GADMobileAds.sharedInstance().start() | ||
}, | ||
load: { | ||
var adUnitID: String { | ||
#if DEBUG | ||
return "ca-app-pub-3940256099942544/4411468910" | ||
#else | ||
return APIKey.googleAdUnitID | ||
#endif | ||
} | ||
|
||
let ad = try await GADInterstitialAd.load(withAdUnitID: adUnitID, request: GADRequest()) | ||
|
||
return GoogleAd(ad: ad) | ||
} | ||
) | ||
} | ||
} | ||
|
||
public struct GoogleAd: Equatable { | ||
public var ad: GADInterstitialAd | ||
|
||
public init(ad: GADInterstitialAd) { | ||
self.ad = ad | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
Projects/Core/Services/Sources/SocialLogin/Util/APIKey.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// APIKey.swift | ||
// CoreKit | ||
// | ||
// Created by kyuchul on 6/17/24. | ||
// Copyright © 2024 com.jordyma.blink. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum APIKey { | ||
static let kakao = getInfoValue(for: "KAKAO_NATIVE_APP_KEY") | ||
static let googleAdUnitID = getInfoValue(for: "GOOGLE_AD_UNITID") | ||
|
||
private static func getInfoValue(for key: String) -> String { | ||
guard let infoDictionary = Bundle.main.infoDictionary, | ||
let value = infoDictionary[key] as? String else { | ||
fatalError("Wrong \(key)") | ||
} | ||
return value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// BKGoogleAdView.swift | ||
// Feature | ||
// | ||
// Created by kyuchul on 11/30/24. | ||
// Copyright © 2024 com.kyuchul.blink. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
import Services | ||
|
||
import GoogleMobileAds | ||
|
||
struct BKGoogleAdView: UIViewControllerRepresentable { | ||
@Binding private var isPresented: Bool | ||
@Binding private var interstitialAd: GoogleAd? | ||
private let dismissAdScreen: () -> Void | ||
private let viewController: UIViewController | ||
|
||
init(isPresented: Binding<Bool>, | ||
interstitialAd: Binding<GoogleAd?>, | ||
dismissAdScreen: @escaping () -> Void | ||
) { | ||
self._isPresented = isPresented | ||
self._interstitialAd = interstitialAd | ||
self.dismissAdScreen = dismissAdScreen | ||
self.viewController = UIViewController() | ||
} | ||
|
||
func makeUIViewController(context: Context) -> UIViewController { | ||
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1)) { | ||
if let interstitialAd { | ||
interstitialAd.ad.present(fromRootViewController: viewController) | ||
} | ||
} | ||
|
||
return viewController | ||
} | ||
|
||
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} | ||
|
||
func makeCoordinator() -> Coordinator { | ||
Coordinator(parent: self) | ||
} | ||
} | ||
|
||
extension BKGoogleAdView { | ||
final class Coordinator: NSObject, GADFullScreenContentDelegate { | ||
private let parent: BKGoogleAdView | ||
|
||
init(parent: BKGoogleAdView) { | ||
self.parent = parent | ||
super.init() | ||
parent.interstitialAd?.ad.fullScreenContentDelegate = self | ||
} | ||
|
||
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { | ||
parent.isPresented.toggle() | ||
parent.dismissAdScreen() | ||
} | ||
} | ||
} |
Oops, something went wrong.