Skip to content

Commit

Permalink
[ADD] GoogleAdUnitID 스킴 분기 처리 (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkyuchul committed Dec 1, 2024
1 parent 76b5971 commit 3c7e7ae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Projects/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<false/>
<key>KAKAO_NATIVE_APP_KEY</key>
<string>$(KAKAO_NATIVE_APP_KEY)</string>
<key>GOOGLE_AD_UNITID</key>
<string>$(GOOGLE_AD_UNITID)</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSApplicationQueriesSchemes</key>
Expand Down
10 changes: 9 additions & 1 deletion Projects/Core/Services/Sources/GoogleAds/GoogleAdsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ extension GoogleMobileAdsClient: DependencyKey {
await GADMobileAds.sharedInstance().start()
},
load: {
let ad = try await GADInterstitialAd.load(withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: GADRequest())
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)
}
Expand Down
17 changes: 0 additions & 17 deletions Projects/Core/Services/Sources/SocialLogin/Util/APIKey.swift

This file was deleted.

22 changes: 22 additions & 0 deletions Projects/Core/Services/Sources/Util/APIKey.swift
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
}
}

0 comments on commit 3c7e7ae

Please sign in to comment.