GADNativeCustomTemplateAd

@interface GADNativeCustomTemplateAd : GADNativeAd

Native custom template ad. To request this ad type, you need to pass kGADAdLoaderAdTypeNativeCustomTemplate (see GADAdLoaderAdTypes.h) to the |adTypes| parameter in GADAdLoader’s initializer method. If you request this ad type, your delegate must conform to the GADNativeCustomTemplateAdLoaderDelegate protocol.

  • The ad’s custom template ID.

    Declaration

    Swift

    var templateID: String { get }

    Objective-C

    @property (readonly, nonatomic) NSString *_Nonnull templateID;
  • Array of available asset keys.

    Declaration

    Swift

    var availableAssetKeys: [String] { get }

    Objective-C

    @property (readonly, nonatomic) NSArray<NSString *> *_Nonnull availableAssetKeys;
  • Returns video controller for controlling receiver’s video.

    Declaration

    Swift

    var videoController: GADVideoController { get }

    Objective-C

    @property (readonly, strong, nonatomic)
        GADVideoController *_Nonnull videoController;
  • Returns media view for rendering video loaded by the receiver. Returns nil if receiver doesn’t has a video.

    Declaration

    Swift

    var mediaView: GADMediaView? { get }

    Objective-C

    @property (readonly, strong, nonatomic, nullable) GADMediaView *mediaView;
  • Custom click handler. Set this property only if this template ad is configured with a custom click action, otherwise set it to nil. If this property is set to a non-nil value, the ad’s built-in click actions are ignored and |customClickHandler| is executed when a click on the asset is received.

    Declaration

    Swift

    var customClickHandler: GADNativeAdCustomClickHandler { get set }

    Objective-C

    @property (readwrite, copy, atomic)
        GADNativeAdCustomClickHandler _Nonnull customClickHandler;
  • Returns the native ad image corresponding to the specified key or nil if the image is not available.

    Declaration

    Swift

    func image(forKey key: String) -> GADNativeAdImage?

    Objective-C

    - (GADNativeAdImage *_Nullable)imageForKey:(nonnull NSString *)key;
  • Returns the string corresponding to the specified key or nil if the string is not available.

    Declaration

    Swift

    func string(forKey key: String) -> String?

    Objective-C

    - (NSString *_Nullable)stringForKey:(nonnull NSString *)key;
  • Call when the user clicks on the ad. Provide the asset key that best matches the asset the user interacted with. If this ad is configured with a custom click action, ensure the receiver’s customClickHandler property is set before calling this method.

    Declaration

    Swift

    func performClickOnAsset(withKey assetKey: String)

    Objective-C

    - (void)performClickOnAssetWithKey:(nonnull NSString *)assetKey;
  • Call when the ad is displayed on screen to the user. Can be called multiple times. Only the first impression is recorded.

    Declaration

    Swift

    func recordImpression()

    Objective-C

    - (void)recordImpression;
  • Call when the user clicks on the ad. Provide the asset key that best matches the asset the user interacted with. Provide |customClickHandler| only if this template is configured with a custom click action, otherwise pass in nil. If a block is provided, the ad’s built-in click actions are ignored and |customClickHandler| is executed after recording the click.

    This method is deprecated. See performClickOnAssetWithKey: API.

    Declaration

    Swift

    func performClickOnAsset(withKey assetKey: String, customClickHandler: (() -> Void)? = nil)

    Objective-C

    - (void)performClickOnAssetWithKey:(nonnull NSString *)assetKey
                    customClickHandler:
                        (dispatch_block_t _Nullable)customClickHandler;