What are firebase Native Ads Advanced in Google admob?

AdMob Native Advanced Ads allows you to create customized promotions that matches your application theme.

AdMob Native Advanced Ads SDK send the advertisement segments specifically to your application, and you render them in your local application code, conveying an awesome user experience.

Developer have freedom to display Native Advanced Ads in Application according to their Application theme, required Ad format.

In iOS applications, the implementation of Google admob  is quite easy. Google AdMob offers different ad formats, so you can choose the one that best fits your app’s user experience. following are the 5 ad formats:

  • Banner
  • Interstitial
  • Native
  • Rewared Video

Here will will explain each format in details.

We can import AdMob SDK in our project manually as well as via pods. its more better if we use pods to import adMob SDK in our project. its more save and affective. If we use Pods to import adMob SDK in our project, we don’t have to replace new SDK manually.

Following are the steps to create a podfile in the project:

  1. Open the terminal
  2. go to the iOS project repository
  3. Initialize Pods: $ pod init.
    it will create file with named podfile.
    podfile initialization
    This photo describes how to create podfile via terminal.

Following are the steps to import AdMob sdk in your iOS project:

  1. open podfile in xcode
  2. write this command to import AdMob sdk in your project: pod ‘Firebase/AdMob’
    Save the file
    command for AdMob
    Opening podfile in Xcode
  3. Now run following command on terminal to install podfile:  $ pod install.
    It will create podfile directory, profile.lock and project workspace file with .xcworkspace extension in your project repository. After installation of project you will do all or your work on your project’s workspace file i.e. (AdMob.xcworkspace).
    installing podfile
    It will install all frameworks linked with AdMob.

Now initialize the AdMob SDK in AppDelegate by calling a class method “configureWithApplicationId” in GADMobileAds and will pass theAdMob App Id.

import UIKit
import GoogleMobileAds

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool 
    {
        GADMobileAds.configure(withApplicationID: "ca-app-pub-59976442137585919481")
        return true
     }
}

Now your AsMob SDK is integrated and imported in your AppDelegate class. Now the next step is to use Google AdMob ad formats in our project.
Here are the detailed use of all 4 add Google AdMob ad formats:

  • Banner
    Banner Ads are mostly shown in the form of a rectangular images. GADBannerView is used to display Banner Ads in iOS applications. So we  will import GADBannerView in our class where we want to show the Banner Ad.

    There are two ways to display Banner Add in your app:
    1) You can display Banner add via interface builder by adding GADBannerView in your storyboard or xib.
    2) or can display it programmatically by instantiating GADBannerView directly in the desired class.
    AdMob Banner Ad
    AdMob Banner Ad

    Here is the detailed example code:

    import UIKit
    import GoogleMobileAds
    
    class ViewController: UIViewController {
          
         @IBOutlet weak var bannerView: GADBannerView!
        
         override func viewDidLoad() {
    
            super.viewDidLoad()
           bannerView.adUnitID = "ca-app-pub-5996076442137585/6101393284"
           bannerView.adUnitID = "ca-app-pub-5996076442137585/6101393284" 
           bannerView.rootViewController = self
           bannerView.load(GADRequest())      
        }
    }
    

    Here is the declaration of all delegates for GADBannerView

  • extension ViewController: GADBannerViewDelegate {
    
    
    // Tells the delegate an ad request loaded an ad.
    
        func adViewDidReceiveAd(_ bannerView: GADBannerView) {
            print("adViewDidReceiveAd")
        }
    
        /// Tells the delegate an ad request failed.
    
        func adView(_ bannerView: GADBannerView,
                    didFailToReceiveAdWithError error: GADRequestError) {
    
            print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
        }
    
        /// Tells the delegate that a full-screen view will be presented in response
    
        /// to the user clicking on an ad.
    
        func adViewWillPresentScreen(_ bannerView: GADBannerView) {
    
            print("adViewWillPresentScreen")
    
        }
    
        /// Tells the delegate that the full-screen view will be dismissed.
    
        func adViewWillDismissScreen(_ bannerView: GADBannerView) {
    
            print("adViewWillDismissScreen")
        }
    
        /// Tells the delegate that the full-screen view has been dismissed.
    
        func adViewDidDismissScreen(_ bannerView: GADBannerView) {
    
            print("adViewDidDismissScreen")
        }
    
        /// Tells the delegate that a user click will open another app (such as
    
        /// the App Store), backgrounding the current app.
    
        func adViewWillLeaveApplication(_ bannerView: GADBannerView) {
    
            print("adViewWillLeaveApplication")
        }
    }
  • Interstitial
     These Ads are displayed on full and users click on close button to dismiss these Ads.
    We use GADInterstitial to display Interstitial Ads in ours apps.
    The 
    step to display interstitial Ads are:
    1) Instantiate an instance of GADInterstitial.

    2) ads its unit Id in viewDidLoad.
    3) create a GADRequest request and then load it to instance of GADInterstitial
    4) Now you can present this ad on the screen when required.
    adMob Interstitial Ad iOS
    adMob Interstitial Ad iOS

    Here is an example to instantiate and display Interstitial Ads:

    import UIKit
    import GoogleMobileAds
    
    class ViewController: UIViewController {
          
       var interstitial: GADInterstitial!
        
         override func viewDidLoad() {
    
            super.viewDidLoad()
           interstitial = GADInterstitial(adUnitID: "ca-app-pub-5996076002137585/4900086331")
    
           let request = GADRequest()
    
           interstitial.load(request) 
        }
    }
    
    override func viewDidAppear(_ animated: Bool) {
    
            if interstitial.isReady {
                interstitial.present(fromRootViewController: self)
            } else {
                print("Ad was not available/ready")
            }
        }
    
    
  • Rewarded Video
    Rewarded Video are full screen video ads. main purpose to show these ads.

copyright : http://developine.com

Contact Us