# Native iOS

### Contents

* [1 CocoaPods (preferred)](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [2 Manual download](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [2.1 POKKT Native iOS SDK v8.1.0 (GDPR Compliance)](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [2.2 Pokkt iOS SDK Integration Guide v8.1.0](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [3 SDK Configuration](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [4 Full-Screen Ads](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [5 Banner Ads](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [6 Native Ads](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [7 Display Native Ad](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [8 Additional SDK Configuration](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [8.1 GDPR](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [9 Extra Parameter](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [10 ThirdPartyUser Id](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [11 User Detail](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [12 Pokkt AdPlayer Configuration](broken://pages/VPaOuTi4FdZj15jrbkmF)
* [13 Migration Note Guide v 8.1.0](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.1 Screen ID](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.2 AdTypes](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.3 Simpler APIs for full screen ads and banner ads.](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.4 Ad Delegates are changed. SetDelegate API is removed.](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.5 Native Ad](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.6 isAdCached API is changed](broken://pages/VPaOuTi4FdZj15jrbkmF)
  * [13.7 Destroy Banner API is changed](broken://pages/VPaOuTi4FdZj15jrbkmF)

### CocoaPods (preferred)

The simplest way to import the SDK into an iOS project is to use [CocoaPods](https://guides.cocoapods.org/using/getting-started). Open your project's Podfile and add this line to your app's target:

```
pod 'PokktAds'
```

Then from the command line run:

```
pod install
```

If you're new to CocoaPods, see their [official documentation](https://guides.cocoapods.org/using/using-cocoapods) for info on how to create and use Podfiles.

### Manual download

####

Last Update: 29th October, 2021

Download Latest Version Here

***

#### Pokkt iOS SDK Integration Guide v8.1.0

* Download the latest SDK. Here
* Unzip the downloaded file and drag the PokktSDK.framework directory into Xcode under Framework.
* Add the required compiler flags to 'Other Linker Flags' field in your project's Build Settings.
  * -ObjC
  * -lxml2
* Make sure that these frameworks are included to respect the library dependencies:<br>
  * Add Webkit.Framework.
  * ARKit.framework

Error creating thumbnail: File missing

### SDK Configuration

1\. Set Application Id and Security key in Pokkt SDK. You can get it from the Pokkt dashboard from your account. We generally assign unique application-id and security-key.

```
 [PokktAds setPokktConfigWithAppId:appId securityKey:securityKey]; 
```

2\. When your application is under development and if you want to see sdk logs and other informatory messages, you can enable it by setting setDebug to true . Make sure to disable debugging before release.

```
 [PokktDebugger setDebug:<YES/NO>]; 
```

### Full-Screen Ads

1. Full-screen ads can be rewarded or non-rewarded and video or interstitial. You can either cache the ad in advance or directly call show for it.
2. We suggest you cache the ad in advance so as to give seamless play behaviour, In other case it will stream the video which may lead to unnecessary buffering delays depending on the network connection.
3. Screen-Id: ​ This one parameter is accepted by almost all API’s of Pokkt SDK. This controls the placement of ads and can be created on Pokkt Dashboard. We will be referencing the ​PokktAdsDemo ​ app provided with SDK during the course of explanation in this document. We suggest you go through the sample app for better understanding.
4. To cache Full-screen ad call:<br>

   ```
   [PokktAds cacheAd:screenId withDelegate:delegate];
   ```
5. To Show Video Ad:<br>

   ```
   [PokktAds showAd:screenId withDelegate:delegate presentingVC:viewcontroller];
   ```

   \
   You can check if an ad is available, before making a show request.<br>

   ```
   [PokktAds isAdCached:screenId];
   ```
6. Ad actions are optional, but we suggest to implement them as it will help you to keep track of the status of your ad request.<br>

   ```
   /** Caching **/
   - (void)adCachingResult:(NSString *)screenId
   isSuccess:(BOOL)success
   withReward:(double)reward
   errorMessage:(NSString *)errorMessage;
   /** Ad Display **/
   - (void)adDisplayResult:(NSString *)screenId
   isSuccess:(BOOL)success
   errorMessage:(NSString *)errorMessage;
   /** Ad Closed **/
   - (void)adClosed:(NSString *)screenId adCompleted:(BOOL)adCompleted;
   /** Ad Interaction **/
   - (void)adClicked:(NSString *)screenId;
   - (void)adGratified:(NSString *)screenId withReward:(double)reward;
   ```

###

1. Load banner Ad call:

   ```
   PokktBannerView *banner = [PokktBanner initWithBannerAdSize:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50)];
   [self.view addSubview:banner];
   [PokktAds showAd:(NSString *)screenId withViewController:(UIViewController *)viewController bannerContainer:(PokktBannerView *)bannerView withDelegate:self];
   ```
2. Refresh banner: You can set banner refresh rate on pokkt dashboard. Refresh rate should be in range of 30 -100
3. Destroy banner

   ```
   [PokktAds destroyBanner:(PokktBannerView *)bannerContainer];
   ```
4. Ad actions are optional, but we suggest to implement them as it will help you to keep track of the status of your ad request.

   ```
   - (void)bannerExpanded:(NSString *)screenId;
   - (void)bannerResized:(NSString *)screenId;
   - (void)bannerCollapsed:(NSString *)screenId;
   ```

### Native Ads

1. A native ad may be served in feed or in between the developer content inside the app. Normally, FullScreen ads are delivered on call to action by the user. Native ads eliminate this limitation and show ads without any user request.Native ads are also non intrusive as they will be automatically paused when the ad is out of the view by scrolling. The PokktNativeAdLayout will be part of developer application parent components which may be ListView, Layout in ScrollView or WebView.\
   Load Native Ad:

   ```
   [PokktAds requestNativeAd:(NSString *)screenId withDelegate:self withNativeAdConfig:(PokktNativeAdConfig*)nativeAdConfig];

   //after calling ’requestNativeAd:withDelegate:’, Inside the -(void)adReady:(NSString *)screenId withNativeAd:(PokktNativeAd *)pokktNativeAd; method you will receive PokktNativeAd object and then extract your ad by calling below method.

   UIView *adView = [pokktNativeAd getMediaView];
   ```
2. Ad actions are optional, but we suggest to implement them as it will help you to keep track of the status of your ad request.<br>

   ```
   - (void)adReady:(NSString *)screenId withNativeAd:(PokktNativeAd *)pokktNativeAd;
   - (void)adFailed
   :(NSString *)screenId error:(NSString *)errorMessage;
   ```

### Display Native Ad

When a native ad loads, your app will receive a native ad object via adReady delegate messages. Your app is then responsible for displaying the ad.

The first step is to create a UIView subclass that will display native ad assets. The class also provides IBOutlets used to register the view used for each individual asset. Below are the header file and nib file format:

```
#import <UIKit/UIKit.h>
@interface PokktNativeAdNibView : UIView
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@property (weak, nonatomic) IBOutlet UILabel *advertizerView;
@property (weak, nonatomic) IBOutlet UIImageView *starRatingView;
@property (weak, nonatomic) IBOutlet UILabel *starRatingLabel;
@property (weak, nonatomic) IBOutlet UILabel *bodyView;
@property (weak, nonatomic) IBOutlet UIButton *callToActionView;
@property (weak, nonatomic) IBOutlet UILabel *priceView;
@property (weak, nonatomic) IBOutlet UILabel *storeView;
@property (weak, nonatomic) IBOutlet UILabel *headlineView;
@property (weak, nonatomic) IBOutlet UIView *mediaView;
@property (weak, nonatomic) IBOutlet UILabel *nativeAd;
@property (weak, nonatomic) IBOutlet UILabel *likeLbl;
@property (weak, nonatomic) IBOutlet UILabel *CTALbl;
@property (weak, nonatomic) IBOutlet UILabel *downloadLbl;
@property (weak, nonatomic) IBOutlet UILabel *saleLbl;
@property (weak, nonatomic) IBOutlet UILabel *phoneNumLbl;
@property (weak, nonatomic) IBOutlet UILabel *address;
@property (weak, nonatomic) IBOutlet UILabel *additionalDescriptive;
@property (weak, nonatomic) IBOutlet UILabel *displayURL;
@end
```

Error creating thumbnail: File missing

Once the layout is complete and the outlets are linked, the last step is to add code to your app that displays an ad once it has loaded. Here's a method to display an ad in the view defined above:

Create a UIView class object in the class where you want to show native ads and pass that object properties to PokktNativeAdViewBinder class.

```
PokktNativeAdNibView *nativeAdView;
```

```
- (void)adReady:(NSString *)screenId withNativeAd:(PokktNativeAd *)pokktNativeAd
{
PokktNativeAdViewBinder *nativeBinder = [[PokktNativeAdViewBinder alloc]
initWithNativeRootView:nativeAdView mediaView:nativeAdView.mediaView
icon:nativeAdView.iconView title:nativeAdView.headlineView
ctaButton:nativeAdView.callToActionView body:nativeAdView.bodyView
sponsor:nativeAdView.advertizerView rating:nativeAdView.starRatingLabel
price:nativeAdView.priceView like:nativeAdView.likeLbl cta:nativeAdView.CTALbl
download:nativeAdView.downloadLbl salePrice:nativeAdView.saleLbl
phoneNumber:nativeAdView.phoneNumLbl address:nativeAdView.address
additionalDescriptive:nativeAdView.additionalDescriptive
displayURL:nativeAdView.displayURL];
[nativeBinder populateView:pokktNativeAd];
[containerView addSubview:nativeAdView];
}
```

Developers will have to do cleanup of Native Ad on viewController deInit.

```
[pokktNativeAd destroy];
```

### Additional SDK Configuration

####

As of May 25th, the General Data Protection Regulation (GDPR) will be enforced in the European Union.

Set *GDPR consent* in Pokkt SDK. This must be called before calling any ad related API. Developers/Publishers must get the consent from user. For more information on GDPR please refer <https://www.eugdpr.org/> and <https://www.eugdpr.org/gdpr-faqs.html> . This API can again be used by publishers to revoke the consent. If this API is not called or invalid data provided then SDK will access the users personal data for ad targeting

```
PokktConsentInfo *consentInfo = [[PokktConsentInfo alloc] init];
consentInfo.isGDPRApplicable = true;
consentInfo.isGDPRConsentAvailable = false;
[PokktAds setPokktConsentInfo:consentInfo];
```

###

You can set extra parameters to POKKT SDK, to be passed back to your server via POKKT server callback. These Extra parameters will be in key-value pair.The key must be alphanumeric value. See the below example

```
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:0];
[dict setValue:@"value1" forKey:@"key1"];
[dict setValue:@"value2" forKey:@"key2"];
[dict setValue:@"value3" forKey:@"key3"];
[PokktAds setCallbackExtraParam:dict];
```

### ThirdPartyUser Id

If you are using server to server integration with Pokkt, you can also set Third Party UserId in PokktAds.

```
PokktAds.setThirdPartyUserId:(NSString*) userId
```

### User Detail

For better targeting of ads you can also provide user details to our SDK using

```
PokktUserDetails *pokktUserDetails = [PokktUserDetails alloc] init];
pokktUserDetails.Name = "";
pokktUserDetails.Age = "";
pokktUserDetails.Sex = "";
pokktUserDetails.MobileNo = "";
pokktUserDetails.EmailAddress = "";
pokktUserDetails.Location = "";
pokktUserDetails.Birthday = "";
pokktUserDetails.MaritalStatus = "";
pokktUserDetails.FacebookId = "";
pokktUserDetails.TwitterHandle = "";
pokktUserDetails.Education = "";
pokktUserDetails.Nationality = "";
pokktUserDetails.Employment = "";
pokktUserDetails.MaturityRating = "";
[PokktAds setPokktUserDetails: pokktUserDetails]
```

### Pokkt AdPlayer Configuration

Pokkt Ad player works the way App is configured at Pokkt dashboard, but we provide a way to override those settings using PokktAdPlayerViewConfig.

Application should prefer configuration provided through code by developer or what’s configured for the app in dashboard, can be controlled any time through the dashboard itself. If you want to make changes to this configuration after your app distribution, you can contact Pokkt Team to do the same for your app through admin console.

```
PokktAdPlayerViewConfig * adPlayerViewConfig = [[PokktAdPlayerViewConfig alloc] init];
// set properties values to adPlayerViewConfig
PokktAds.setAdPlayerViewConfig(adPlayerViewConfig );
```

Various properties that can be managed through this are:

1\. Default skip time\
Defines the time after which user can skip the Ad.\
Property name: DefaultSkipTime\
Values:\
Any Integer value.\
Default value is 10 seconds.<br>

2\. Should allow skip\
Defines if user is allowed to skip the Ad or not.\
Property name: ShouldAllowSkip\
Values:\
True = User can skip Ad.\
False = User can’t skip Ad.<br>

3\. Should allow mute\
Defines if user is allowed to mute the Video Ad or not.\
Property name: ShouldAllowMute\
Values:\
True = User can mute video Ad.\
False = User can’t mute video Ad.<br>

4\. Should confirm skip\
Defines if confirmation dialog is to be shown before skipping the Ad.\
Property name: ShouldConfirmSkip\
Values:\
True = Confirmation dialog will be shown before skipping the video.\
False = Confirmation dialog will not be shown before skipping the video.<br>

5\. Skip confirmation message\
Defines what confirmation message to be shown in skip dialog.\
Property name: SkipConfirmMessage\
Values:\
Any String message.\
Default value is “Skipping this video will earn you NO rewards. Are you sure?”.<br>

6\. Affirmative label for skip dialog\
Defines what should be the label for affirmative button in skip dialog.\
Property name: SkipConfirmYesLabel\
Values:\
Any String message.\
Default value is “Yes”.<br>

7\. Negative label for skip dialog\
Defines what should be the label for affirmative button in skip dialog.\
Property name: SkipConfirmNoLabel\
Values:\
Any String message.\
Default value is “No”.<br>

8\. Skip timer message\
Defines message to be shown before enabling skip button. Don’t forget to add placeholder “ ## ” in your custom message. This placeholder is replaced by property “Default skip time” assigned above.\
Property name: setSkipTimerMessage\
Values:\
Any String message.\
Default value is “You can skip video in ## seconds”<br>

9\. Incentive message\
Defines message to be shown during video progress, that after what time user will be incentivised.\
Property name: setIncentiveMessage\
Values:\
Any String message\
Default value is “more seconds only for your reward !”<br>

10\. AudioEnabled\
AudioEnabled set YES or NO to mute ad,if 'YES' ad will be mute. , default is NO.\
Property name: isAudioEnabled\
Values:\
True = If you want to mute Ad.\
False = If you don’t want to mute Ad.<br>

11\. Should collect feedback\
Defines message to be shown during video progress, that after what time user will be incentivised.\
Property name setShouldCollectFeedback\
Values:\
True = If you want to collect feedback from the user for the Ad.\
False = If you don’t want to collect feedback from the user for the Ad.

### Migration Note Guide v 8.1.0

* In case of any query regarding integration, refer “PokktSDK Integration Guide (iOS, v8.1.0)” for this version provided inside “PokktSDK\_v8.1.0”.

**Screen ID**

ScreenId is accepted by almost all API’s of Pokkt SDK. This controls the placement of ads and can be created on Pokkt Dashboard. This replaced Screen Name used earlier.

**AdTypes**

Rewarded Video ads and Interstitial Ads are merged into full screen ad type and ad type can be changed in runtime by editing the screen id Ad type.

**Simpler APIs for full screen ads and banner ads.**

```
[PokktVideoAds cacheRewardedVideoAd: (NSString*) screenName];
[PokktVideoAds cacheNonRewardedVideoAd: (NSString*) screenName];
[PokktInterstitial cacheRewarded (NSString*) screenName];
[PokktInterstitial cacheNonRewarded: (NSString*) screenName];

is now 

[PokktAds cacheAd:screenId withDelegate:delegate];
```

```
[PokktVideoAds showRewardedVideoAd:(NSString*) screenName
viewController:(UIViewController*)viewController];

[PokktVideoAds showNonRewardedVideoAd:(NSString*)
screenName viewController:(UIViewController*)viewController];

[PokktInterstitial showRewarded :(NSString*)
screenName viewController:(UIViewController *)viewController];

[PokktInterstitial showNonRewarded :(NSString*)
screenName viewController:(UIViewController *)viewController];

 is now 

[PokktAds showAd:screenId withDelegate:delegate presentingVC:viewcontroller]; 
```

```
[PokktBanner loadBanner:banner withScreenName:(NSString*) screenName
rootViewContorller:(PokktBannerView *)bannerView];

 is now 

UIView  *banner = [UIView initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50)];
[self.view addSubview:banner];

[PokktAds showAd:screenTF.text withDelegate:self
     inContainer:banner]; 
```

**Ad Delegates are changed. SetDelegate API is removed.**

```
[PokktVideoAdsDelegate setPokktVideoAdsDelegate:self];

- (void)videoAdCachingCompleted: (NSString *)screenName isRewarded: (BOOL)isRewarded reward:
(float)reward;

- (void)videoAdCachingFailed: (NSString *)screenName isRewarded: (BOOL)isRewarded errorMessage: (NSString
*)errorMessage;

- (void)videoAdCompleted: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)videoAdDisplayed: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)videoAdClicked: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)videoAdGratified: (NSString *)screenName reward:(float)reward;

- (void)videoAdSkipped: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)videoAdClosed:(NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)videoAdFailedToShow: (NSString *)screenName isRewarded: (BOOL)isRewarded errorMessage: (NSString
*)errorMessage;

 is now 

- (void)adCachingResult:(NSString *)screenId 
              isSuccess:(BOOL)success 
             withReward:(double)reward 
           errorMessage:(NSString *)errorMessage; 

- (void)adDisplayResult:(NSString *)screenId 
              isSuccess:(BOOL)success 
           errorMessage:(NSString *)errorMessage;
 
- (void)adClosed:(NSString *)screenId 
     adCompleted:(BOOL)adCompleted; 

- (void)adClicked:(NSString *)screenId; 

- (void)adGratified:(NSString *)screenId 
         withReward:(double)reward; 

- (void)adReady:(NSString *)screenId 
   withNativeAd:(PokktNativeAd *)pokktNativeAd;
 
- (void)adFailed:(NSString *)screenId 
           error:(NSString *)errorMessage; 
```

```
[PokktInterstitial setPokktInterstitialDelegate:self];;

- (void)interstitialCachingCompleted: (NSString *)screenName isRewarded: (BOOL)isRewarded reward:
(float)reward;

- (void)interstitialCachingFailed: (NSString *)screenName isRewarded: (BOOL)isRewarded errorMessage:
(NSString *)errorMessage;

- (void)interstitialCompleted: (NSString *)screenName isRewarded: (BOOL)isRewarded; 
check

- (void)interstitialDisplayed: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)interstitialClicked: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)interstitialGratified: (NSString *)screenName reward:(float)reward;

- (void)interstitialSkipped: (NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)interstitialClosed:(NSString *)screenName isRewarded: (BOOL)isRewarded;

- (void)interstitialFailedToShow: (NSString *)screenName isRewarded: (BOOL)isRewarded errorMessage:
(NSString *)errorMessage;

 is now 

- (void)adCachingResult:(NSString *)screenId 
              isSuccess:(BOOL)success 
             withReward:(double)reward 
           errorMessage:(NSString *)errorMessage; 

- (void)adDisplayResult:(NSString *)screenId 
              isSuccess:(BOOL)success 
           errorMessage:(NSString *)errorMessage;
 
- (void)adClosed:(NSString *)screenId 
     adCompleted:(BOOL)adCompleted; 

- (void)adClicked:(NSString *)screenId; 

- (void)adGratified:(NSString *)screenId 
         withReward:(double)reward; 

- (void)adReady:(NSString *)screenId 
   withNativeAd:(PokktNativeAd *)pokktNativeAd;
 
- (void)adFailed:(NSString *)screenId 
           error:(NSString *)errorMessage; 
```

**Native Ad**

Native Ads are introduced which replaces OutStream ads. Please refer to our documentation for details.

**isAdCached API is changed**

```
[PokktVideoAds isAdCached:(NSString *)screenName isRewarded:(BOOL)isRewarded];

[PokktInterstitial
isAdCached:(NSString *)screenName isRewarded:(BOOL)isRewarded];

is now 
[PokktAds isAdCached:screenId];
```

```
[PokktBanner destroyBanner:<PokktBannerView>];

is now 

[PokktAds dismissAd: screenId]; 
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.pokkt.com/pokkt-sdk-plugins/native-ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
