iOS SDK  7.3.0
 All Classes Files Functions Properties Pages
FlurryAdNative Class Reference

Provides all available methods for displaying native ads. More...

#import <FlurryAdNative.h>

Inherits NSObject.

Instance Methods

(id) - initWithSpace:
 Initialize the native ad object. More...
 
(void) - fetchAd
 Fetch an ad for this ad object. More...
 
(NSArray *) - assetListForType:
 List of assets that match the specified asset type. More...
 
(void) - removeTrackingView
 Removes the tracking view associated with the ad object. More...
 
(BOOL) - isVideoAd
 Method which returns if its a video Ad. More...
 
(void) - setPencilViewToTrack:withExpandButton:andCTAButton:
 Sets up Pencil view to track which will be used to send impression beacons. A click on this view sets the display state to expanded and the delegate callback adNativeExpandToggled: is invoked. The cta button provided in this call is used to invoke landing page. More...
 
(void) - setExpandedViewToTrack:withExpandButton:andCTAButton:
 Sets up expanded view to track which will be used to send click beacons. A click on this view loads the landing page. The expand button provided in this call is used to collpase the expanded view of ad. More...
 

Properties

NSString * space
 Read only property that can be used to retrieve the ad space that was passed into an initializer routine. An Ad Space is an area within your app that is designated to display ads. Ad spaces need to be setup and configured on the Flurry developer portal. More...
 
id< FlurryAdNativeDelegateadDelegate
 Sets the object to receive various delegate methods. More...
 
BOOL ready
 Returns if an ad is currently ready to display for this ad object. More...
 
BOOL expired
 Returns if an ad has expired. More...
 
kFlurryAdNativeDisplayState displayState
 List of assets that match the specified asset type. More...
 
NSArray * assetList
 This property will retrieve the native ad's assets. The assets will be available when the ad is ready. More...
 
UIView * trackingView
 The UIView that needs click tracking. More...
 
UIViewController * viewControllerForPresentation
 This property should be set to the view controller that needs to be used to present a full screen when the ad is clicked. Typically this will the topmost content view controller. More...
 
UIView * videoViewContainer
 This property should be set to the view which will have the Video Player embedded for Native Video Ads. More...
 
FlurryAdTargetingtargeting
 This property should be used for ad targeting based on parameters such as location, targeting kewords, age and gender. More...
 

Detailed Description

Provides all available methods for displaying native ads.

Set of methods that allow publishers to configure, target, and deliver native ads to their customers.

For information on how to use Flurry's Ads SDK to attract high-quality users and monetize your user base see Support Center - Publishers.

Author
2009 - 2014 Flurry, Inc. All Rights Reserved.
Version
6.0.0

Definition at line 34 of file FlurryAdNative.h.

Method Documentation

- (NSArray*) assetListForType: (kAssetType)  type

List of assets that match the specified asset type.

This property can be used to retrieve a subset of the assets based on the asset view type.

Since
6.0.0
See Also
FlurryAdNativeAsset::kAssetType for the list of available asset types.
- (void) fetchNativeAd
{
FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:adSpace];
nativeAd.adDelegate = self;
[nativeAd fetchAd];
}
- (void) adNativeDidFetchAd:(FlurryAdNative*) nativeAd
{
NSArray* imageAssets = [nativeAd assetListForType:ASSET_TYPE_IMAGE]
// user imageAssets in your app
}
Returns
Array of assets for the specified asset type
- (void) fetchAd

Fetch an ad for this ad object.

Since
6.0.0
Note
The ad will be fetched using the ad space that was passed into initializer routines.
This method must be called sometime after startSession: (Flurry)
See Also
ready: for details on verifying is an ad is ready to be displayed.
- adNativeDidFetchAd: (FlurryAdNativeDelegate-p) for details on the notification of ads being received.
- adNative:adError:errorDescription: (FlurryAdNativeDelegate-p) for details on notification of failure to receive ads from this request.
-(void) loadAds:(NSUInteger) count
{
NSString* adSpace = @"STREAM_ADS";
for (int ix = 0; ix < count; ix++)
{
FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:adSpace];
nativeAd.adDelegate = self;
[nativeAd fetchAd];
[self.nativeAds addObject:nativeAd];
}
}
- (id) initWithSpace: (NSString *)  space

Initialize the native ad object.

Since
6.0.0

This method initializes the ad object and gets it ready to fetch and serve a native ad.

FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:@"STREAM_ADS"];
Parameters
spacerepresents the placement of the ad in your app. Typically all native ads that are presented within a single view controller will have the same ad space. For example, a carousel or a stream table view may have the following spaces "CAROUSEL_ADS" and "STREAM_ADS".
- (BOOL) isVideoAd

Method which returns if its a video Ad.

Use this property to figure out if its a Video Ad

Note
It is very important to set viewControllerForPresentation and videoViewContainer for the current Video Ad Integration
Since
6.6.0
See Also
viewControllerForPresentation and videoViewContainer
@interface AdStreamCell : UITableViewCell
@property (nonatomic, retain) FlurryAdNative* ad;
@property (weak, nonatomic) IBOutlet UIView *videoView;
@end
@implementation AdStreamCell
- (void) setupAdCellForNativeAd:(FlurryAdNative*) nativeAd
{
if([self.ad isVideoAd])
{
self.ad.videoViewContainer = videoView;
}
}
- (void) removeTrackingView

Removes the tracking view associated with the ad object.

Set this property prior to the reuse of a UIView to ensure that the view is not tracked by more than one ad object.

Note
It is very important to set trackingView to nil or call removeTrackingView before the UIView cell associated with this ad is reused.
Since
6.0.0
See Also
trackingView
@interface AdStreamCell : UITableViewCell
@property (nonatomic, retain) FlurryAdNative* ad;
@end
@implementation AdStreamCell
- (void) setupAdCellForNativeAd:(FlurryAdNative*) nativeAd
{
[self.ad removeTrackingView];
self.ad = nativeAd;
self.ad.trackingView = self;
}
- (void) setExpandedViewToTrack: (UIView *)  expandedView
withExpandButton: (UIButton *)  expandButton
andCTAButton: (UIButton *)  ctaButton 

Sets up expanded view to track which will be used to send click beacons. A click on this view loads the landing page. The expand button provided in this call is used to collpase the expanded view of ad.

Note
The expand button can't be nil.
Since
7.3.0
- (void)setupWithFlurryNativeAd:(FlurryAdNative*)adNative atPosition:(NSInteger)position displayType:(kFlurryAdNativeDisplayState)displayType
{
[self.ad removeTrackingView];
self.ad = adNative;
self.ad.displayState = displayType;
if (adNative.assetList == nil)
{
self.frame = CGRectMake(0, 0, 0, 0);
return;
}
if ([Utils isPortrait]) {
[self adjustForPortrait];
} else {
[self adjustForLandscape:adNative];
}
self.cardTitleLabel.textColor = [UIColor blackColor];
if (displayType == FLURRY_NATIVE_AD_EXPANDED)
{
[self showExpanded];
[self.ad setExpandedViewToTrack:self withExpandButton:self.expandButton andCTAButton:nil];
} else {
[self showCollapsed];
[self.ad setPencilViewToTrack:self withExpandButton:self.expandButton andCTAButton:self.CTASquareImageButton];
}
}
Parameters
expandedViewA UIView used to build the native ad in expanded state
expandButtonA UIButton to collapse to pencil view. Please use the collapse button of the expanded view
ctaButtonA UIButton to open the landing page from expanded view.
- (void) setPencilViewToTrack: (UIView *)  pencilView
withExpandButton: (UIButton *)  expandButton
andCTAButton: (UIButton *)  ctaButton 

Sets up Pencil view to track which will be used to send impression beacons. A click on this view sets the display state to expanded and the delegate callback adNativeExpandToggled: is invoked. The cta button provided in this call is used to invoke landing page.

Note
The expand button can't be nil.
Since
7.3.0
- (void)setupWithFlurryNativeAd:(FlurryAdNative*)adNative atPosition:(NSInteger)position displayType:(kFlurryAdNativeDisplayState)displayType
{
[self.ad removeTrackingView];
self.ad = adNative;
self.ad.displayState = displayType;
if (adNative.assetList == nil)
{
self.frame = CGRectMake(0, 0, 0, 0);
return;
}
if ([Utils isPortrait]) {
[self adjustForPortrait];
} else {
[self adjustForLandscape:adNative];
}
self.cardTitleLabel.textColor = [UIColor blackColor];
if (displayType == FLURRY_NATIVE_AD_EXPANDED)
{
[self showExpanded];
[self.ad setExpandedViewToTrack:self withExpandButton:self.expandButton andCTAButton:nil];
} else {
[self showCollapsed];
[self.ad setPencilViewToTrack:self withExpandButton:self.expandButton andCTAButton:self.CTASquareImageButton];
}
}
Parameters
pencilViewA UIView used to build the native ad in collapsed state
expandButtonA UIButton to expand the pencil view. Please use the expand button of the pencil view
ctaButtonA UIButton to open the landing page from minimal view.

Property Documentation

- (id<FlurryAdNativeDelegate>) adDelegate
readwritenonatomicweak

Sets the object to receive various delegate methods.

Since
6.0.0

This method allows you to register an object that will receive notifications at different phases of native ad serving.

See Also
FlurryAdNativeDelegate for details on delegates available.
-(void) fetchNativeAd;
{
FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:adSpace];
nativeAd.adDelegate = self;
[nativeAd fetchAd];
}
Parameters
delegateThe object to receive notifications of various ad actions.

Definition at line 68 of file FlurryAdNative.h.

- (NSArray*) assetList
readnonatomicstrong

This property will retrieve the native ad's assets. The assets will be available when the ad is ready.

Since
6.0.0
See Also
FlurryAdNativeAsset for details on the assets.
for (int ix = 0; ix < adNative.assetList.count; ix++)
{
FlurryAdNativeAsset* asset = [adNative.assetList objectAtIndex:ix];
if ([asset.name isEqualToString:@"headline"])
{
self.streamTitleLabel.text = asset.value;
}
if ([asset.name isEqualToString:@"summary"])
{
self.streamDescriptionLabel.text = asset.value;
}
}
Returns
Array of FlurryAdNativeAsset objects

Definition at line 218 of file FlurryAdNative.h.

- (kFlurryAdNativeDisplayState) displayState
readwritenonatomicassign

List of assets that match the specified asset type.

This property can be used to set the exapnd state of the ad. User need to set this value appropriately. Default is FLURRY_NATIVE_AD_EXPANDED

Since
7.3.0
See Also
FlurryAdNative::kFlurryAdNativeDisplayState for the list of available display types.
- (IBAction)expandBtnTapped:(id)sender {
if (self.ad.displayState == FLURRY_NATIVE_AD_COLLAPSED)
{
self.ad.displayState = FLURRY_NATIVE_AD_EXPANDED;
[self showExpanded];
} else if (self.ad.displayState == FLURRY_NATIVE_AD_EXPANDED) {
self.ad.displayState = FLURRY_NATIVE_AD_COLLAPSED;
[self showCollapsed];
}
}
Returns
Array of assets for the specified asset type

Definition at line 192 of file FlurryAdNative.h.

- (BOOL) expired
readnonatomicassign

Returns if an ad has expired.

Since
6.3.0

This method will verify if the ad associated with this native ad object has expired. Please call fetch again or discard this native ad object and create a new native object when the ad expires

Note
a native ad object can expire after it is ready, so it is necessary to test for expiry while the native ad is in use.
See Also
- fetchAd for details on retrieving an ad.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
{
// map table row to index within an array of prefetched native ads
// isAdRow and adIndexForIndexPathRow will be methods defined in your code
NSInteger adIx = [self adIndexForIndexPathRow:indexPath.row];
if ([self isAdRow:indexPath.row] && [[self.nativeAds objectAtIndex:adIx] ready] == YES)
{
// AdCell here is a user defined class that will setup a xib view using the assets in a native ad
AdCell* adCell = [tableView dequeueReusableCellWithIdentifier:@"FlurryStreamCell" forIndexPath:indexPath];
// check if ad has expired and then show or display ad cell as appropriate
if ([[self.nativeAds objectAtIndex:adIx] expired] == YES)
{
// ad associated with this native ad object has expired, fetch a new ad
FlurryAdNative* nativeAd = [self.nativeAds objectAtIndex:adIx];
[nativeAd fetchAd];
// hide ad cell until ad is available
adCell.hidden = YES;
}
else
{
FlurryAdNative* nativeAd = [self.nativeAds objectAtIndex:adIx];
[adCell setupWithFlurryNativeAd:nativeAd atPosition:indexPath.row];
adCell.hidden = NO;
}
}
else
{
// setup app content xib cells
}
}
Returns
YES/NO to indicate if an ad is ready to be displayed.

Definition at line 160 of file FlurryAdNative.h.

- (BOOL) ready
readnonatomicassign

Returns if an ad is currently ready to display for this ad object.

Since
6.0.0

This method will verify if an ad is currently available for this ad object. If an ad is not available, you can call fetchAd: to load a new ad.

Note
If this method returns YES, an ad will be available and the assetList will be populated. It is advisable to listen to the delegate adNative:adError:errorDescription: (FlurryAdNativeDelegate-p) to get notified if the ad fetch request fails.
See Also
#fetch for details on retrieving an ad.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
{
// map table row to index within an array of prefetched native ads
// isAdRow and adIndexForIndexPathRow will be methods defined in your code
NSInteger adIx = [self adIndexForIndexPathRow:indexPath.row];
if ([self isAdRow:indexPath.row] && [[self.nativeAds objectAtIndex:adIx] ready] == YES)
{
// AdCell here is a user defined class that will setup a xib view using the assets in a native ad
AdCell* adCell = [tableView dequeueReusableCellWithIdentifier:@"FlurryStreamCell" forIndexPath:indexPath];
FlurryAdNative* nativeAd = [self.nativeAds objectAtIndex:adIx];
[adCell setupWithFlurryNativeAd:nativeAd atPosition:indexPath.row];
}
else
{
// setup app content xib cells
}
}
Returns
YES/NO to indicate if an ad is ready to be displayed.

Definition at line 105 of file FlurryAdNative.h.

- (NSString*) space
readnonatomiccopy

Read only property that can be used to retrieve the ad space that was passed into an initializer routine. An Ad Space is an area within your app that is designated to display ads. Ad spaces need to be setup and configured on the Flurry developer portal.

Since
6.0.0
Returns
The ad space string value.

Definition at line 44 of file FlurryAdNative.h.

- (FlurryAdTargeting*) targeting
readwritenonatomicstrong

This property should be used for ad targeting based on parameters such as location, targeting kewords, age and gender.

Since
6.0.0
See Also
FlurryAdTargeting for details on the assets including asset names.
Returns
The Ad Targeting object that was orignally set or nil if never set.

Definition at line 315 of file FlurryAdNative.h.

- (UIView*) trackingView
readwritenonatomicstrong

The UIView that needs click tracking.

Set this property to track clicks on a view. For a table view controller the UITableViewCell that is used to display the ad can be set as the tracking view.

Note
It is very important to set trackingView to nil or call removeTrackingView before the ad cell is reused.
Since
6.0.0
See Also
- removeTrackingView
@interface AdStreamCell : UITableViewCell
@property (nonatomic, retain) FlurryAdNative* ad;
@end
@implementation AdStreamCell
- (void) setupAdCellForNativeAd:(FlurryAdNative*) nativeAd
{
[self.ad removeTrackingView];
self.ad = nativeAd;
self.ad.trackingView = self;
}
Returns
View tracked by this ad object or nil if a tracking view has not been set on this object.

Definition at line 254 of file FlurryAdNative.h.

- (UIView*) videoViewContainer
readwritenonatomicstrong

This property should be set to the view which will have the Video Player embedded for Native Video Ads.

Since
6.6.0
See Also
FlurryAdNativeAsset for details on the video assets
FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:adSpace];
nativeAd.adDelegate = self;
nativeAd.videoViewContainer = self.videoViewContainer;
[nativeAd fetchAd];
Returns
UIView used for presenting the Flurry Video Player

Definition at line 301 of file FlurryAdNative.h.

- (UIViewController*) viewControllerForPresentation
readwritenonatomicstrong

This property should be set to the view controller that needs to be used to present a full screen when the ad is clicked. Typically this will the topmost content view controller.

Since
6.0.0
See Also
FlurryAdNativeAsset for details on the assets including asset names.
FlurryAdNative* nativeAd = [[FlurryAdNative alloc] initWithSpace:adSpace];
nativeAd.adDelegate = self;
[nativeAd fetchAd];
Returns
UIViewcontroller used for presentation of a full screen or nil if a presenting view controller has not been set

Definition at line 279 of file FlurryAdNative.h.


The documentation for this class was generated from the following file: