Google Mobile Ads iOS Examples

repository·main·Indexed 21 days ago

https://github.com/googleads/googleads-mobile-ios-examples

Open-source example applications and developer resources for integrating the Google Mobile Ads SDK into iOS apps. Includes Swift and Objective-C implementations for AdMob and Google Ad Manager, covering ad formats such as App Open, Banner, Interstitial, Native Advanced, Rewarded Interstitial, and Rewarded Video. Projects use CocoaPods for dependency management and include API demo snippets used in official documentation.

Tokens
1.7K
Snippets
5
Records
16
Agent score
75%

What's inside googleads-mobile-ios-examples

  1. Explore Swift and Objective-C implementation examples

    main

    This repository provides categorized code examples for both AdMob and AdManager in Swift and Objective-C.

    Swift Examples

    • AdMob: Includes App Open, Banner, Interstitial, Native Advanced, Rewarded Interstitial, and Rewarded Video examples.
    • Advanced: Includes an APIDemo, InlineAdaptiveBannerExample (for UITableView), and a SwiftUI demo.
    • AdManager: Includes App Open, Banner, Interstitial, Rewarded Video, and Custom Rendering examples.

    Objective-C Examples

    • AdMob: Includes App Open, Banner, Full Screen Native, Instream, Interstitial, Native Advanced, Rewarded Interstitial, and Rewarded Video examples.
    • Advanced: Includes an APIDemo and InlineAdaptiveBannerExample.
    • AdManager: Includes App Open, Banner, Interstitial, Rewarded Video, and Custom Rendering examples.
  2. Install and run Google Mobile Ads SDK examples

    main

    The example apps in this repository use CocoaPods for dependency management. To run an example, follow these steps:

    1. Navigate to the directory containing the Podfile for the specific example you want to run.
    2. Install the dependencies by running pod install.
    3. [Optional] If you want to use the latest version of the SDK instead of the version specified in Podfile.lock, run pod update.
    4. Open the .xcworkspace file in Xcode.
    5. Build and run the app from Xcode.
    # Install dependencies
    pod install
    
    # Optional: Update to latest SDK version
    pod update
  3. Set up the iOS Banner Example using Cocoapods

    main

    This example demonstrates how to place a banner ad in an iOS application. It is designed to work with Cocoapods to manage the Google Mobile Ads SDK dependency.

    To set up the project:

    1. Ensure Cocoapods is installed on your system.
    2. Run pod update in the project directory to install the required SDK dependencies.
    3. Open the generated .xcworkspace file in Xcode to build and run the application.
    pod update
  4. Access Google Mobile Ads SDK documentation and support

    main

    For technical guidance and official documentation, use the following resources:

  5. Use the iOS Rewarded Interstitial Ad Example

    main

    This project provides a minimal Objective-C example demonstrating the implementation of rewarded interstitial ads in an iOS application.

    Key Integration Details:

    • SDK Management: The example does not bundle the Google Mobile Ads SDK directly. Instead, it is configured to use CocoaPods. You can install the necessary dependencies by using the provided Podfile in the project directory.
    • Language: Objective-C.
  6. Install the Google Mobile Ads SDK via CocoaPods

    main
    This example project uses CocoaPods to manage the Google Mobile Ads SDK dependency. To install the SDK and prepare the project for building, run pod update in the project directory. This command will resolve dependencies and generate a .xcworkspace file. You must open and run the .xcworkspace file instead of the .xcodeproj file to ensure the SDK is correctly linked.
    pod update
  7. Configure your Ad Unit ID for Rewarded Interstitial Ads

    main

    The example includes a preconfigured ad unit ID for demonstration purposes. To use this in a production application, you must replace the placeholder ID with your own unique ad unit ID.

    Steps to configure:

    1. Sign in to the AdMob console.
    2. Create a new Rewarded Interstitial ad unit.
    3. Copy your unique Ad Unit ID.
    4. Replace the existing ID in the example code with your new ID.
  8. Setup the Full Screen Native Example using CocoaPods

    main

    This project is compatible with CocoaPods and includes a Podfile. To install the necessary dependencies, including the Google Mobile Ads SDK, run the following command in your terminal. This will generate a .xcworkspace file which you should use to open and run the project.

    Note: If you do not have CocoaPods installed, you must install it first following the official CocoaPods guides.

    pod update