Feed Type (iOS)
BuzzAd Benefit SDK: Feed
This documentation provides a guideline for integrating feed for BuzzAd Benefit.
※ Note
Please proceed with the following process only after BuzzAd Benefit SDK integration is complete.
The feed accommodates customization of the design of toolbar, ad list item and header.
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
Create the
BABFeedConfig
withunit_id
.Create a
BABFeedHandler
using the theBABFeedConfig
as its object.Create a
BABFeedViewController
by callingpopulateViewController()
.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 thetopInset
with the desired values by setting theshouldOverrideTopInset
andtopInset
properties of theBABFeedViewController
.
Recommended Usage
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 adsfeedHandler.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 preloadedBABFeedHandler
.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 thepopulateViewController()
with the same instance will display the same preloaded ads. By callingpopulateViewController()
with a newBABFeedHandler
, 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.
Create a that implements
BABFeedHeaderView
.Configure the view through the interface builder or code.
Override
desiredHeight
to specify the height of the desiredheaderView
.
Specify the
headerViewClass
viaBABFeedConfig
.
Customizing the Feed Ad List View
The ad list view of the feed can be customized and callbacks for ad events can be registered.
Implement a class that inherits
BABAdViewHolder
.Configure the view through the interface builder or code.
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(optional) Implement necessary customizations for the state-specific callbacks for the ad. (Refer to the document for event definitions and actions).
Specify the
adViewHolderClass
viaBABFeedConfig
.
Separator Customization between Feed Items
The color, height and horizontalMargin of the separator between feed items can be customized.