iOS SDK Version

FBNativeAdCollectionViewAdProvider

Objective-C
@interfaceFBNativeAdCollectionViewAdProvider:NSObject
Swift
classFBNativeAdCollectionViewAdProvider:NSObject
Additional functionality on top of FBNativeAdsManager to assist in using native ads within a UICollectionView. This class contains a mechanism to map indexPaths to native ads in a stable manner as well as helpers which assist in doing the math to include ads at a regular interval within a collection view.
  • Passes delegate methods from FBNativeAd. Separate delegate calls will be made for each native ad contained.

    Declaration

    Objective-C
    @property(nonatomic,weak,nullable)id<FBNativeAdDelegate>delegate;
    Swift
    weakvardelegate:FBNativeAdDelegate?{getset}
  • FBAdExtraHint to provide extra info

    Declaration

    Objective-C
    @property(nonatomic,strong,nullable)FBAdExtraHint*extraHint;
    Swift
    varextraHint:FBAdExtraHint?{getset}
  • Create a FBNativeAdCollectionViewAdProvider.

    Declaration

    Objective-C
    -(nonnullinstancetype)initWithManager:(nonnullFBNativeAdsManager*)manager;
    Swift
    init(manager:FBNativeAdsManager)

    Parameters

  • Retrieve a native ad for an indexPath, will return the same ad for a given indexPath until the native ads manager is refreshed. This method is intended for usage with a collection view and specifically the caller is recommended to wait until collectionView:cellForRowAtIndexPath: to ensure getting the best native ad for the given collection cell.

    Declaration

    Objective-C
    -(nonnullFBNativeAd*)collectionView:(nonnullUICollectionView*)collectionViewnativeAdForRowAtIndexPath:(nonnullNSIndexPath*)indexPath;
    Swift
    funccollectionView(_collectionView:UICollectionView,nativeAdForRowAtindexPath:IndexPath)->FBNativeAd

    Parameters

    Return Value

    A FBNativeAd which is loaded and ready to be used.
  • Support for evenly distributed native ads within a collection view. Computes whether this cell is an ad or not.

    Declaration

    Objective-C
    -(BOOL)isAdCellAtIndexPath:(nonnullNSIndexPath*)indexPathforStride:(NSUInteger)stride;
    Swift
    funcisAdCell(atindexPath:IndexPath,forStridestride:UInt)->Bool

    Parameters

    Return Value

    Boolean indicating whether the cell at the path is an ad
  • Support for evenly distributed native ads within a collection view. Adjusts a non-ad cell indexPath to the indexPath it would be in a collection with no ads.

    Declaration

    Objective-C
    -(nullableNSIndexPath*)adjustNonAdCellIndexPath:(nonnullNSIndexPath*)indexPathforStride:(NSUInteger)stride;
    Swift
    funcadjustNonAdCellIndexPath(_indexPath:IndexPath,forStridestride:UInt)->IndexPath?

    Parameters

    Return Value

    An indexPath adjusted to what it would be in a collection view with no ads
  • Support for evenly distributed native ads within a collection view. Adjusts the total count of cells within the collection view to account for the ad cells.

    Declaration

    Objective-C
    -(NSUInteger)adjustCount:(NSUInteger)countforStride:(NSUInteger)stride;
    Swift
    funcadjustCount(_count:UInt,forStridestride:UInt)->UInt

    Parameters

    Return Value

    The total count of cells within the collection view including both ad and non-ad cells