Hello! Google Mobile Ads team, This is MK.
Currently, I am publishing native ad/banner ad advertisements using AdManager.
The code I am using is as follows.
final class GoogleADLoader {
let adUnitID: String
let rootViewController: UIViewController
let widthOfBannerSize: CGFloat
private lazy var adLoader: GADAdLoader = {
let adLoader = GADAdLoader(
adUnitID: self.adUnitID,
rootViewController: self.rootViewController,
adTypes: [.native, .gamBanner],
options: nil
)
adLoader.delegate = self
return adLoader
}()
init(adUnitID: String, rootViewController: UIViewController) {
self.adUnitID = adUnitID
self.rootViewController = rootViewController
self.widthOfBannerSize = rootViewController.view.window?.windowScene?.screen.fixedCoordinateSpace.bounds.width ?? 0
}
func fetchAD(
with contentURLStrings: [String],
customTargetings: [String: String]
) {
let gamRequest = GAMRequest()
gamRequest.neighboringContentURLStrings = contentURLStrings
gamRequest.customTargeting = customTargetings
adLoader.load(gamRequest)
}
}
extension GoogleADLoader: GADAdLoaderDelegate {
public func adLoader(_ adLoader: GADAdLoader, didFailToReceiveAdWithError error: any Error) {
print(error)
}
public func adLoaderDidFinishLoading(_ adLoader: GADAdLoader) {}
}
extension GoogleADLoader: GADNativeAdLoaderDelegate {
public func adLoader(_ adLoader: GADAdLoader, didReceive nativeAd: GADNativeAd) {
print(nativeAd)
}
}
extension GoogleADLoader: GAMBannerAdLoaderDelegate {
public func adLoader(_ adLoader: GADAdLoader, didReceive bannerView: GAMBannerView) {
print(bannerView)
}
public func validBannerSizes(for adLoader: GADAdLoader) -> [NSValue] {
[NSValueFromGADAdSize(GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(widthOfBannerSize))]
}
}
In this structure, is it possible to call only banner ads with AdManager and only native ads with AdMob?
If possible, I would like to know how.
Thank you for always responding kindly.