NativeDataSource is an implementation of the UITableViewDataSource protocol that manages the placement of native ads within native contents.
After loading your data, pass them to NativeDataSource to let it manage:
[nativeDataSource insertData:dataLoaded];
After loading native ad from your ad provider, pass it to NativeDataSource to let it manage:
[nativeDataSource insertNativeAd:nativeAdLoaded];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[nativeDataSource setVisibleIndexPath:indexPath]; // required for dynamic ad placement
if ([nativeDataSource isNativeAdAtIndexPath:indexPath]) {
[nativeDataSource.data objectAtIndex:indexPath.row]; // this is native ad
...
} else {
[nativeDataSource.data objectAtIndex:indexPath.row]; // this is native content
...
}
}
To run the example project, clone the repo, and run pod install from the Example directory first.
iOS SDK 7.0 and above
NativeDataSource is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "NativeDataSource"
NativeDataSource is available under the MIT license. See the LICENSE file for more info.