GANSearchAdController Class

GANSearchAdController Class Reference

Overview

Retrieves search ads and makes them available to the client of the SDK.

Inherits NSObject.

Instance Method Summary

(instancetype) - NS_UNAVAILABLE
 
(instancetype) - initWithPublisherID:styleID:options:delegate:
 Initializes the ad controller. More...
 
(void) - loadAds:
 Retrieves, asynchronously, the first page of ads for the given adRequest, and subsequent pages as needed. More...
 
(void) - loadMoreAds
 Retrieves, asynchronously the next page of ads for the previous request specified by the last call to loadAds:. More...
 
(NSInteger) - adCount
 Returns the (cumulative) number of ads loaded so far for the current call to loadAds:. More...
 
(GANAdView *) - adView
 Create an empty adView. More...
 
(void) - populateAdView:identifier:
 Populate an adView with the ad specified by the identifier. More...
 

Property Summary

NSString * publisherID
 The publisher id used for ad requests. More...
 
NSString * styleID
 The settings id used for ad requests. More...
 
GANSearchAdControllerOptionsoptions
 The options used for all ad requests. More...
 

Method Detail

- (instancetype) initWithPublisherID: (NSString *)  publisherID
styleID: (NSString *)  styleID
options: (nullable GANSearchAdControllerOptions *)  options
delegate: (nullable id< GANSearchAdControllerDelegate >)  delegate 

Initializes the ad controller.

Parameters
publisherIDThe publisher id, e.g. "ms-app-pub-9616389000213823".
styleIDThe settings id for the template that will be used to render native ads.
optionsGANSearchAdControllerOptions, such as whether to prefetch ads, adTest, adSafe, etc.
delegateGANSearchAdControllerDelegate for receiving notifications when ads are loaded and other events.
- (void) loadAds: (GANSearchAdRequest *)  adRequest

Retrieves, asynchronously, the first page of ads for the given adRequest, and subsequent pages as needed.

This method should be called only once per request: if the option prefetchEnabled is YES, subsequent pages will be retrieved automatically. When new ads are loaded (or fail to load) the GANSearchAdControllerDelegate will be called on the main thread.

Parameters
adRequestThe GANSearchAdRequest query.
- (void) loadMoreAds

Retrieves, asynchronously the next page of ads for the previous request specified by the last call to loadAds:.

If loadAds: has not been called, this will return an error through the GANSearchAdControllerDelegate. If there is a full page of ads that have not been shown, this will also return an error to the delegate.

- (NSInteger) adCount

Returns the (cumulative) number of ads loaded so far for the current call to loadAds:.

- (GANAdView *) adView

Create an empty adView.

- (void) populateAdView: (GANAdView *)  view
identifier: (NSString *)  adIdentifier 

Populate an adView with the ad specified by the identifier.

  • if adIdentifier is a new identifier, the view will show the next available ad.
  • if adIdentifier has already been used, the view will show the same ad it showed the first time this method was called with adIdentifier.
    Parameters
    viewThe GANAdView to populate.
    adIdentifierAn ad identifier used to identify this ad. This can be any NSString. Each unique string will be assigned to the next available ad until ads are exhausted.

Property Detail

- (NSString*) publisherID
readnonatomiccopy

The publisher id used for ad requests.

- (NSString*) styleID
readnonatomiccopy

The settings id used for ad requests.

- (GANSearchAdControllerOptions*) options
readnonatomicstrong

The options used for all ad requests.