Does anyone have an example of how to implement a Google mobile ads adMob Smart Banner that supports orientation changes in Swift?
I couldn't find it neither on StackOverflow nor on the Google documentation.
Thanks
Does anyone have an example of how to implement a Google mobile ads adMob Smart Banner that supports orientation changes in Swift?
I couldn't find it neither on StackOverflow nor on the Google documentation.
Thanks
Link: https://developers.google.com/mobile-ads-sdk/docs/dfp/ios/quick-start
I hope useful for you!
Best regards.
There is an example of the Smart Banner implementation in the swift demos of AdMob APIDemo Just download the repository and try the demo.
Note that it doesn't resize the banner when rotating the device. You still need to figure out that part.
Your new "finished example" code would be:
import UIKit
import GoogleMobileAds
class ViewController: UIViewController {
@IBOutlet weak var bannerView: DFPBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
print("Google Mobile Ads SDK version: " + DFPRequest.sdkVersion())
bannerView.adSize = kGADAdSizeSmartBannerLandscape
bannerView.adUnitID = "/6499/example/banner"
bannerView.rootViewController = self
bannerView.loadRequest(DFPRequest())
}
}
You can find the example code for Swift in GitHub.
GoogleAds-Mobile-iOS-Swift