WLNativeAdsCollectionMode.h 5.5 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 WLNativeAdsCollectionMode
 The Collection View mode for integrating native ads in a UICollectionView
 @copyright Warply Inc.
 */


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

/*!
 @protocol WLNativeAdsCollectionModeDelegate
 @abstract If there is a need for showing the content of native ad the user must create an option that conforms to the WLNativeAdsCollectionModeDelegate 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 WLNativeAdsCollectionModeDelegate <NSObject>

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

@end


/*!
 @class WLNativeAdsCollectionMode
 @discussion This class handles the integration of native ads in a UICollectionView. It manages the datasource and the delegate of the original UICollectionView and returns a collectionView with native ads embeded as per user choice. All the delegates and datasource methods are executed in case the original class executes them.
 */
@interface WLNativeAdsCollectionMode : NSObject

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

/*!
 * @methodgroup Initialising the CollectionView mode of native ads
 */
/*!
 * @abstract Initializes the WLNativeAdsCollectionMode object.
 * @discussion This class handles and integrates native ads in an original UICollectionView object.
 * @param viewController The View Controller where the original collectionView exists.
 * @param collectionView The original collectionView object where we will add the native ads.
 * @param startPosition The position where the ads will start to appear in the collectionView. It counts from 0.
 * @param frequency The frequency with which the ads will appear in the collectionView.
 * @param size The size 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 <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout> *)viewController CollectionView:(UICollectionView *)collectionView withStartPosition:(NSInteger)startPosition Frequency:(NSInteger)frequency CellSize:(CGSize)size 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 WLCustomNativeCollectionViewCell 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:(WLCustomNativeCollectionViewCell *)cell withIdentifier:(NSString *)cellIdentifier andNibName:(NSString *)nibName;


/*!
 @methodgroup Handling the native Ads CollectionView
 */
/*!
 *  @abstract Refresh the collectionView datasource and delegate.
 *  @discussion Call this method when the datasource of the original collectionView will change. For example call this function after an asynchronous update of the data of the collectionView.
 *  @param collectionView The original collectionView object which will change after the update.
 */
-(void)refreshAdsForCollectionView:(UICollectionView *)collectionView;
/**
 *  @abstract Defines if the ads will appear in a repeatable way in the collectionView.
 *  @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 collectionView. Default value is NO.
 *  @param repeatable BOOL value that sets if the native ads will repeat themselves in the collectionView.
 */
-(void)setRepeatable:(BOOL)repeatable;
//-(NSIndexPath *)getOriginalIndexPath:(NSIndexPath *)indexPath;

@end