Shopable Video Ad Unit

Before You Start Make Sure:

Shopable Video

Shopable Video is designed to be inserted into a UITableView or UIScrollView.
Each Shopable Video is associated with an UIView.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == AD_POSITION) {
        UIView *view = [self.ad view];
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AD" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if (cell.contentView.subviews.count > 0) [cell.contentView.subviews[0] removeFromSuperview];
        [cell.contentView addSubview:view];
        [cell.contentView.leadingAnchor constraintEqualToAnchor:view.leadingAnchor].active = YES;
        [cell.contentView.trailingAnchor constraintEqualToAnchor:view.trailingAnchor].active = YES;
        [cell.contentView.topAnchor constraintEqualToAnchor:view.topAnchor].active = YES;
        [cell.contentView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor].active = YES;

        return cell;
    } else {
        return [tableView dequeueReusableCellWithIdentifier:@"IDENTIFIER" forIndexPath:indexPath];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == AD_POSITION) {
        return [(DIOShoppableView*)[self.ad view] height];
    } 
}

In order to customize ad container objects and text colors use optional setters on ShoppableVideoPlacement object as shown in example:

 DIOShoppableView *shopView = (DIOShoppableView*)[self.ad view];
    shopView.containerBackground = UIColor.blueColor;
    shopView.containerBorderColor = UIColor.greenColor;
    shopView.titleColor = UIColor.redColor;
    shopView.productNameColor = UIColor.redColor;
    shopView.rateStarFillColor = UIColor.redColor;
    shopView.rateTextColor = UIColor.redColor;
    shopView.productPriceColor = UIColor.redColor;
    shopView.productInfoColor = UIColor.redColor;
    shopView.buttonColor = UIColor.redColor;
    shopView.buttonBorderColor = UIColor.blueColor;
    shopView.buttonTextColor = UIColor.greenColor;
    [shopView reloadShoppableView];

Besides standard event handler Shopable Video ad unit supports click event handler that allows to track user activity (clicks on UI elements) and handle click events respectfully, for example redirect user to product page or product reviews page or to the cart:

    [self.ad setShoppableAction:^(DIOShoppableClickEvent clickEvent) {
        switch (clickEvent) {
            case UNDEFINED:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  UNDEFINED");
                break;
            case ADCONTAINER:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  ADCONTAINER");
                break;
            case ADCONTENT:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  ADCONTENT");
                break;
            case PRODUCTIMAGE:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTIMAGE");
                break;
            case PRODUCTVIDEO:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTVIDEO");
                break;
            case BUTTON:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  BUTTON");
                break;
            case PRODUCTNAME:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTNAME");
                break;
            case PRODUCTRATE:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTRATE");
                break;
            case PRODUCTINFO:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTINFO");
                break;
            case PRODUCTREVIEWS:
                NSLog(@"AD_CLICK_EVENT_HANDLER:  PRODUCTREVIEWS");
                break;
        }
    }];

There are additional methods available in order to control Shopable Video behaviour in case of switching between fragments:

  • Call [ad finish] to stop the ad and release the resources associated with it.
  • Call [ad leave] to pause the video ad.
  • Call [ad reenter] to resume the video ad.

 

Still have Questions?

Contact Us