Before You Start Make Sure:
- App and Placement set up on Publisher Portal
- SDK is installed
- SDK is initialized
- Each Ad request has "Testing" status which enables it to test integrations.
Outstream Video ad unit supports only Video ad format and provides an option to snap ad view and stick it to top of your app content. Outstream Video is designed to be inserted into an UITableView. Each Outstream Video is associated with an UIView. But Outstream Video loading process is handled in a different way than the other ad units:
#import <DIOSDK/DIOOutstreamVideoContainer.h>
#import <DIOSDK/DIOOutstreamVideoView.h>
...
@property (nonatomic, strong) DIOOutstreamVideoContainer *container;
@property (nonatomic, strong) DIOAd *ad;
DIOPlacement *placement = [[DIOController sharedInstance]
placementWithId:@"<YOU_PLACEMENT_ID>"];
DIOAdRequest *request = [placement newAdRequest];
self.container = [[DIOOutstreamVideoContainer alloc] init];
[self.container loadWithAdRequest:request completionHandler:^(DIOAd *ad){
self.ad = ad; // Success
} errorHandler:^(NSError *error) {
// Failure
}];
The main difference is that you don’t have to wait to receive a DIOAd object in order to access the Outstream Video UIView. In order to do so use:
DIOOutstreamVideoView *view = (DIOOutstreamVideoView*)
[self.container view];
Then if the view is not detached (i.e. it has not reached the top of the screen), you can add it to your UITableViewCell:
if (!view.detached) {
// Add to cell
}
When the UITableView requires the height of the row containing the Outstream Video, you should return:
[(DIOOutstreamVideoView*)[self.container view] height];
By default, the frame and text in Outstream Video use black/gray for background color and white for text. You can customise a color scheme to get the best appearance within your table:
((DIOOutstreamVideoPlacement*)placement).backgroundColor = [UIColor...];
((DIOOutstreamVideoPlacement*)placement).backgroundColorSnap = [UIColor...];
((DIOOutstreamVideoPlacement*)placement).color = [UIColor...];
((DIOOutstreamVideoPlacement*)placement).colorSnap = [UIColor...];
In order to control Outstream Video behavior in case of switching between screens:
- Call [self.ad finish] to stop the ad and release the resources associated with it.
- Call [self.ad leave] to pause the video ad.
- Call [self.ad reenter] to resume the video ad.
In order to detect if Outstream Video was clicked, subscribe to the <DIOAdClickDelegate> protocol and then define yourself as a delegate via:
self.ad.clickDelegate = self;
Finally implement the following to be notified whenever relevant:
- (void)onAdClicked:(DIOAd*)ad;
Check the Sample App for a fully-working example.
Comments
0 comments
Please sign in to leave a comment.