Feed Type (iOS)

BuzzAd Benefit SDK: Feed


This documentation provides a guideline for integrating feed for BuzzAd Benefit.

※ Note

  1. Please proceed with the following process only after BuzzAd Benefit SDK integration is complete.

  2. The feed accommodates customization of the design of toolbar, ad list item and header.

  3. Please proceed with the Advanced Usage only after implementing all of the features in Basic Usage.

 

Index

 

Basic Usage


Setting the BABFeedConfig and the BABFeedHandler

  1. Create the BABFeedConfig with unit_id.

  2. Create a BABFeedHandler using the the BABFeedConfig as its object.

  3. Create a BABFeedViewController by calling populateViewController().

  4. Display the BABFeedViewController on the screen.

 

// Objective-C BABFeedConfig *config = [[BABFeedConfig alloc] initWithUnitId:YOUR_FEED_UNIT_ID]; config.title = @"Feed"; BABFeedHandler *feedHandler = [[BABFeedHandler alloc] initWithConfig:config]; BABFeedViewController *feedViewController = [feedHandler populateViewController]; // Push to navigation [self.navigationController pushViewController:feedViewController animated:YES]; // Or present as modal // [self presentViewController:feedViewController animated:YES completion:nil];

 

// Swift let config = BABFeedConfig(unitId: YOUR_FEED_UNIT_ID) config.title = "Feed" let feedHandler = BABFeedHandler(with: config) let feedViewController = feedHandler.populateViewController() // Push to navigation navigationController?.pushViewController(feedViewController, animated: YES) // Or present as modal // present(feedViewController, animated: YES, completion: nil)

Note : Using a custom navigation bar of attaching BABFeedViewController as a childViewController of another viewController may cause issues related to topInset not being set correctly. In this case, override the topInset with the desired values by setting the shouldOverrideTopInsetand topInset properties of the BABFeedViewController.


Checking for the Ad Status

At times, displaying BABFeedViewController may result in a blank screen when there are no ads available. Therefore, it is recommended to call preload and receive onSuccess to check the ad status so that feed activity can be started only when there are ads available.

  • feedHandler.adsCount : The number of ads

  • feedHandler.availableReward : The total amount of reward available

     

// Objective-C [feedHandler preloadWithOnSuccess:^{ NSUInteger adsCount = feedHandler.adsCount; double availableReward = feedHandler.availableReward; } onFailure:^(NSError * _Nonnull error) { // Error when there is no ad available }];

 

 

Note

  • The method populateViewController() must be called on the same object as the preloaded BABFeedHandler.

    • If ads are preloaded in a BABFeedHandler instance, the instance will continue to hold the same ads. Hence, even if the user leaves the activity, calling the populateViewController() with the same instance will display the same preloaded ads. By calling populateViewController() with a new BABFeedHandler, new ads will be shown each time the feed activity is started.

 

Advanced Usage


Design Customization

ToolBar Customization

The design of the toolbar at the top of the feed can be customized by modifying the properties of the navigationBar.

 

Customizing the Header

Customizing the header can be done to provide more information to the users.

  1. Create a that implements BABFeedHeaderView.

    1. Configure the view through the interface builder or code.

    2. Override desiredHeight to specify the height of the desired headerView.




       

  2. Specify the headerViewClass via BABFeedConfig.




 

Customizing the Feed Ad List View

The ad list view of the feed can be customized and callbacks for ad events can be registered.

  1. Implement a class that inherits BABAdViewHolder.

    1. Configure the view through the interface builder or code.

    2. Implement renderAd to bind ad property to the view component. There may be times when reward is not available for an ad either because only a very short time has passed since the user has been rewarded for the same ad or because the ad did not have reward to begin with. Therefore, when configuring the ad layout, please check to see the availability (ad.reward > 0) of a reward to decide whether to show the reward on the UI or not

    3. (optional) Implement necessary customizations for the state-specific callbacks for the ad. (Refer to the document for event definitions and actions).






  2. Specify the adViewHolderClass via BABFeedConfig.




 

Separator Customization between Feed Items

The color, height and horizontalMargin of the separator between feed items can be customized.