Small Layout Ad is mediation of standard units that can be configured from the PubNative dashboard. Small Layout Ad view contains a predefined set of icon, banner, title, description, CTA and disclosure view. You can choose an ad type from PubNative dashboard like banner only, description-banner-icon or, title-icon-description etc.

Predefined fixed size for Small layout Ad view is 320 x 80.

153

Small Layout Example

Getting Started

  • Before integrating Small Layout Ads in your app, you’ll need to go through the steps in our Getting started guide, create an account on PubNative and integrate the SDK into your project.
  • Add a Small Layout Ad unit to your app in the PubNative dashboard.
  • Make sure you have added the ad network SDKs you wish to use in your app.

For Small Layout Ads, first, you need to create a layout, then integrate lifecycle callbacks and load the ad. After these steps, you can start using it.

Integration Steps

Create Small Layout

You can create predefined Small Layout ad request using PNSmallLayout.

let smallLayout = PNSmallLayout()
PNSmallLayout *smallLayout = [[PNSmallLayout alloc] init];

Integrate Lifecycle Callbacks for Small Layout

You can track the load process with callbacks using PNLayoutLoadDelegate.

class YourClass: PNLayoutLoadDelegate 
{
//...
func layoutDidFinishLoading(_ layout: PNLayout!)
{
    // Layout loaded
}

func layout(_ layout: PNLayout!, didFailLoading error: Error!)
{
    // Layout load failed
}
//...
}
@interface YourClass () <PNLayoutLoadDelegate>
//...
- (void)layoutDidFinishLoading:(PNLayout *)layout
{
    // Layout loaded
}

- (void)layout:(PNLayout *)layout didFailLoading:(NSError *)error
{
    // Layout load failed
}
//...

You can track the tracking process, user interaction and ad behavior with callbacks using PNLayoutTrackDelegate. But you should set delegate only when Layout has been already loaded.
You need to set the delegate as;

class YourClass: PNLayoutTrackDelegate 
{
//...
smallLayout.trackDelegate = self
//...
func layoutTrackClick(_ layout: PNLayout!) 
{
    // Layout click tracked
}
    
func layoutTrackImpression(_ layout: PNLayout!) 
{
    // Layout impression tracked
}
//...
}
@interface YourClass () <PNLayoutTrackDelegate>
//...
smallLayout.trackDelegate = self;
//...
- (void)layoutTrackImpression:(PNLayout *)layout
{
    // Layout impression tracked
}

- (void)layoutTrackClick:(PNLayout *)layout
{
    // Layout click tracked
}
//...

Load Small Layout Ad

To load Small Layout Ad;

smallLayout.load(withAppToken: "<YOUR_APP_TOKEN>", placement: "<YOUR_PLACEMENT>", delegate: self)
[smallLayout loadWithAppToken:@"<YOUR_APP_TOKEN>" placement:@"<YOUR_PLACEMENT>" delegate:self];

In order to get callbacks from PNLayout, you should implement PNLayoutLoadDelegate for your class. Once an ad is loaded, you will get a fully created view that can be placed in any view.

Use Small Layout Ad

Once the load callback is over, this layout returns, as a result, an initialized view that can be used inside your own ad container. Impressions and clicks are tracked directly from the SDK, but you need to call startTrackingView() method so the layout starts listening for clicks and checking the ad on the screen. You can extract the view from smallLayout.viewController.view.

Any interaction with this method without a previously loaded layout will do nothing.

let layoutView = smallLayout.viewController.view
// Inject the view into your view container
smallLayout.startTrackingView()
UIView *layoutView = smallLayout.viewController.view;
// Inject the view into your view container
[smallLayout startTrackingView];

It is highly recommended that if you have a scrolling view and you want to stop tracking the ad view (which is recommended when the ad disappears from the screen), you can use the stopTrackingView() method.

smallLayout.stopTrackingView()
[smallLayout stopTrackingView];