PubNative Library is used to implement API based native ads in iOS. PubNative SDK is a mediation layer for integrating multiple ad networks inside your app with the remote control using the PubNative Dashboard.

It means using PubNative Mediation SDK you can integrate PubNative network as well as other multiple ad networks in your app to implement native and standard ads. If you are using PubNative Library in your app, you can migrate to PubNative SDK by following these simple steps.

Step 1. Requirements

Before migrating from PubNative Library to PubNative SDK, you need to get Placement Name and App Token configured in the PubNative Dashboard and OS should be greater than 8.0. Other requirements will remain same for PubNative SDK.

Step 2. Replace Dependency

If you have imported PubnativeLibrary.Framework, remove it from your project and clone the repository and drag'n'drop the sdk/sdk folder into your app (be sure to check the "Copy items into destination group's folder" option).

Step 3. Change Ad request

Pubnative Library uses PNAdRequestParameters and PNAdRequest for ad request while PubNative SDK uses PNRequest. You need to replace ad request from PNAdRequestParameters and PNAdRequest to PNRequest as following :

#import <PubNativeLibrary/Pubnative.h>
PNAdRequestParameters *parameters = [PNAdRequestParameters requestParameters];
parameters.app_token = @"YOUR_APP_TOKEN_HERE";
__weak typeof(self) weakSelf = self;
self.request = [PNAdRequest request:<YOUR_SELECTED_REQUEST_TYPE>
                    withParameters:parameters
                     andCompletion:^(NSArray *ads, NSError *error) {
   if(error) {
       NSLog(@"Pubnative - error requesting ads: %@", [error description]);
   }else{
       NSLog(@"Pubnative - loaded PNNativeAdModel ads: %d", [ads count]);
   }
}];
[self.request startRequest];

replace it with

let request = PNRequest()
request.startWithAppToken("<APP_TOKEN>", placementName: "<PLACEMENT_NAME>", delegate: self)
PNRequest *request = [[PNRequest alloc] init]
[request startWithAppToken:"<APP_TOKEN>" placementName:"<PLACEMENT_NAME>" delegate: self]

Step 4. Track Ad

Once the ad rendered on screen, you should make the model start tracking your view so we can confirm the impression and handle the clicks, this can be done with the following method from the PubnativeAdModel. you just need to specify the view that contains the ad along with each item to the startTracking method.

Replace

#import <PubNativeLibrary/Pubnative.h>
[PNTrackingManager trackImpressionWithAd:self.ad
                              completion:^(id result, NSError *error)
{
}];

with

ad.startTrackingView(<AD_CONTAINER_VIEW_GROUP>, withViewController:<CONTROLLER>)
[ad startTrackingView:<AD_CONTAINER_VIEW_GROUP> withViewController:<CONTROLLER>];

You can also set up a listener on the model to listen for callbacks on the tracking process.

class YourClass: PNAdModelDelegate {
//...
model.delegate = self
//...
func pubantiveAdDidConfirmImpression(ad: PNAdModel!)
{
    //Impression was just recorded
}
@interface YourInterface () PNAdModelDelegate
//...
model.delegate = self;
//...
- (void)pubantiveAdDidConfirmImpression:(PubnativeAdModel *)ad
{
    //Impression was just recorded
}

- (void)pubnativeAdDidClick:(PubnativeAdModel *)ad
{
    //The ad was clicked, the ad will be opened right after this
}

You can find more about tracking ad view here.