WLNativeAdsTableMode.h 5.29 KB
/*
 Copyright 2010-2016 Warply Inc. All rights reserved.
 
 Redistribution and use in source and binary forms, without modification,
 are permitted provided that the following conditions are met:
 
 1. Redistributions of source code must retain the above copyright notice, this
 list of conditions and the following disclaimer.
 
 2. Redistributions in binaryform must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.
 
 THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*!
 @header WLNativeAdsTableMode
 The Table View mode for integrating native ads in a UITableView
 @copyright Warply Inc.
 */



#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "WLInboxItem.h"
#import "WLCustomNativeAdTableViewCell.h"


/*!
 @protocol WLNativeAdsTableModeDelegate
 @abstract If there is a need for showing the content of native ad the user must create an option that conforms to the WLNativeAdsTableModeDelegate protocol and implement the nativeAdDidSelectWithItem: method.
 */
/*!
 @methodgroup Showing native ad content
 */
/*!
 @abstract Presents the content of the native ad.
 @discussion Receives a WLInboxItem which you can present to a WLInboxViewController. Also, you can handle its data in any custom way.
 */
@protocol WLNativeAdsTableModeDelegate <NSObject>

@optional
- (void)nativeAdDidSelectWithItem:(WLInboxItem *)item;

@end


/*!
 @class WLNativeAdsTableMode
 @discussion This class handles the integration of native ads in a UITableView. It manages the datasource and the delegate of the original UITableView and returns a tableview with native ads embeded as per user choice. All the delegates and datasource methods are executed in case the original class executes them
 */
@interface WLNativeAdsTableMode : NSObject <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, assign) id<WLNativeAdsTableModeDelegate> delegate;


/*!
 @methodgroup Initialising the TableView mode of native ads
 */
/*!
 @abstract Initializes the WLNativeAdsTableMode object.
 @discussion This class handles and integrates native ads in an original UITableView object.
 @param viewController The View Controller where the original tableview exists.
 @param tableView The original tableview object where we will add the native ads.
 @param startPosition The position where the ads will start to appear in the tableView. It counts from 0.
 @param frequency The frequency with which the ads will appear in the tableView.
 @param adHeight The height of the cell the native ad will be presented.
 @param displayType The display type of the campaigns that the user will present as native ads.
 */
-(id)initWithViewController:(UIViewController <UITableViewDataSource,UITableViewDelegate> *)viewController Tableview:(UITableView *)tableView withStartPosition:(NSInteger)startPosition Frequency:(NSInteger)frequency Height:(CGFloat)adHeight andDisplayType:(NSString *)displayType;

/*!
 @methodgroup Setting up a custom cell for native ads
 */
/*!
 *  @abstract Setups a custom cell.
 *  @discussion The user has the option to create his own cell for the native ads and presents the data in his own descression. The custom cell MUST subclass the WLCustomNativeAdTableViewCell object and run the setupCustomCell: method. There, he can manipulate the data of a WLInboxItem. This method is optional.
 *  @param cell           The cell object that user will use as a native Ad cell
 *  @param cellIdentifier The cell's identifier
 *  @param nibName        The nib's name in the case the cell is designed with a .xib file and not in Storyboard.
 */
-(void)setCustomCellForNativeAd:(WLCustomNativeAdTableViewCell *)cell withIdentifier:(NSString *)cellIdentifier andNibName:(NSString *)nibName;

/*!
 @methodgroup Handling the native Ads TableView
 */
/*!
 @abstract Refresh the tableView datasource and delegate.
 @discussion Call this method when the datasource of the original tableView will change. For example call this function after an asynchronous update of the data of the tableView.
 @param tableView The original tableview object which will change after the update.
 */
-(void)refreshAdsForTableView:(UITableView *)tableView;
/*!
 @abstract Defines if the ads will appear in a repeatable way in the tableView.
 @discussion Call this method if you want to set the repeatable property to YES. That means that the ads will be repeated until the end of the tableView. Default value is NO.
 @param repeatable BOOL value that sets fi the native ads will repeat themselves in the tableView.
 */
-(void)setRepeatable:(BOOL)repeatable;
//-(NSIndexPath *)getOriginalIndexPath:(NSIndexPath *)indexPath;

@end