# POKKT SDK Integration Guide v8.2.0 iOS

**Overview**

Thank you for choosing Pokkt SDK for iOS. This document contains all the information required to set up the SDK with your project.

**Downloaded SDK package will contain.**

* Pokkt Documents
* Sample App using PokktSDK

**SDK Integration**

The Pokkt-Ads is installed using CocoaPods. To do this, add the following line to your Podfile. Refer to the below Example 1.

| pod 'Pokkt-Ads' |
| --------------- |

<figure><img src="/files/qCPET9DbFNlhyx5CYtbM" alt=""><figcaption><p><strong>Example 1</strong></p></figcaption></figure>

Then from the command line run:

| pod install |
| ----------- |

Configuring App Transport Security (ATS)

Add the NSAllowsArbitraryLoads to your app's Info.plist file to disable ATS restrictions. As per the Apple guideline, the below code is required to allow a non-secure network, and the default value is false. For additional details [click here.](https://stackoverflow.com/questions/31216758/how-can-i-add-nsapptransportsecurity-to-my-info-plist-file)

| <p>\<key>NSAppTransportSecurity\</key></p><p>\<dict></p><p>\<key>NSAllowsArbitraryLoads\</key></p><p>\<true/></p><p>\</dict></p> |
| -------------------------------------------------------------------------------------------------------------------------------- |

**Adding Your Application to Your Pokkt Publisher's Account**

• Create Account and log-in at [http://www.pokkt.com](http://www.pokkt.com/)

• Add your application and get its application Id and Security key.&#x20;

<figure><img src="/files/kpchiL9J73tw0qD5bLWT" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tQesNUmaSNyIP5GV3R6q" alt=""><figcaption></figcaption></figure>

• Create Screen Ids to be used in AdMob dashboard to set ad source.

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.

Developer needs to create screens in the Pokkt Developer account.

<figure><img src="/files/sVorWir1Uvqc4MGAjCIJ" alt=""><figcaption></figcaption></figure>

### **Implementation Steps** <a href="#heading-h.1fob9te" id="heading-h.1fob9te"></a>

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

First Import the **PokktSDK** and its delegate **PokktAdDelegate** and implement their methods to your project.

| **Objective C**                        | **Swift**                                                   |
| -------------------------------------- | ----------------------------------------------------------- |
| #import \<PokktSDK/PokktAds.h>         | **import** PokktSDK                                         |
| UIViewController <**PokktAdDelegate**> | class ViewController: UIViewController, **PokktAdDelegate** |

**This must be called before calling any other methods of Pokkt SDK**.

| **Objective C**                                                    | **Swift**                                                         |
| ------------------------------------------------------------------ | ----------------------------------------------------------------- |
| \[PokktAds setPokktConfigWithAppId:appId securityKey:securityKey]; | PokktAds.setPokktConfigWithAppId(appId, securityKey: securityKey) |

### **Full-Screen Ads** <a href="#heading-h.3znysh7" id="heading-h.3znysh7"></a>

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.

* To cache Full-screen ad call below method

| **Objective C**                                 | **Swift**                              |
| ----------------------------------------------- | -------------------------------------- |
| \[PokktAds cacheAd:screenId withDelegate:self]; | PokktAds.cacheAd(screenId, with: self) |

* To Show FullScreen ad call the below method

| **Objective C**                                                  | **Swift**                                                 |
| ---------------------------------------------------------------- | --------------------------------------------------------- |
| \[PokktAds showAd:screenId withDelegate:self presentingVC:self]; | PokktAds.showAd(screenId, with: self, presentingVC: self) |

* You can check if an ad is available, before making a show request.

| **Objective C**                  | **Swift**                     |
| -------------------------------- | ----------------------------- |
| \[PokktAds isAdCached:screenId]; | PokktAds.isAdCached(ScreenId) |

**Banner Ads**

* Add Banner to view and Load banner Ad call

| **Objective C**                                                                                                                                                                                                                                                                 | **Swift**                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>Create property</p><p>@property(nonatomic,retain) UIView \*bannerAd;</p><p>CGRect adSize = CGRectMake(0, 100, \[UIScreen mainScreen].bounds.size.width, 50);</p><p>self.bannerAd = \[\[UIView alloc] initWithFrame:adSize];</p><p>\[self.view addSubview:self.bannerAd];</p> | <p>Create property</p><p>@IBOutlet weak var bannerView: UIView!</p><p>PokktAds.showAd(screenId, with: self, inContainer: self.bannerView)</p> |

* To show banner ad, call the below method

| **Objective C**                                                          | **Swift**                                                         |
| ------------------------------------------------------------------------ | ----------------------------------------------------------------- |
| \[PokktAds showAd:screenId withDelegate:self inContainer:self.bannerAd]; | PokktAds.showAd(screenId, with: self, inContainer: self.bannerAd) |

* Refresh banner: You can set a banner refresh rate on the Pokkt dashboard. Refresh rate should be in range of 30 -100
* Destroy banner

| **Objective C**                  | **Swift**                    |
| -------------------------------- | ---------------------------- |
| \[PokktAds dismissAd: screenId]; | PokktAds.dismissAd(screenId) |

* Ad actions are optional, but we suggest implementing them as it will help you to keep track of the status of your ad request.

| **Objective C**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | **Swift**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong>/\*\* Caching \*\*/</strong></p><p>- (void)adCachingResult:(NSString *)screenId</p><p>isSuccess:(BOOL)success withReward:(double)reward</p><p>errorMessage:(NSString *)errorMessage;</p><p><strong>/** Ad Display \*\*/</strong></p><p>(void)adDisplayResult:(NSString *)screenId</p><p>isSuccess:(BOOL)success errorMessage:(NSString *)errorMessage;</p><p><strong>/** Ad Closed \**/</strong></p><p>(void)adClosed:(NSString *)screenId adCompleted:(BOOL)adCompleted;</p><p><strong>/** Ad Interaction \*\*/</strong></p><p>(void)adClicked:(NSString \*)screenId;</p><p>(void)adGratified:(NSString \*)screenId withReward:(double)reward;</p> | <p><strong>/\*\* Caching \*\*/</strong></p><p>- (void)adCachingResult:(NSString *)screenId isSuccess:(BOOL)success withReward:(double)reward errorMessage:(NSString *)errorMessage</p><p><strong>/** Ad Display \*\*/</strong></p><p>- (void)adDisplayResult:(NSString *)screenId isSuccess:(BOOL)success errorMessage:(NSString *)errorMessage</p><p><strong>/** Ad Closed \**/</strong></p><p>- (void)adClosed:(NSString *)screenId adCompleted:(BOOL)adCompleted</p><p><strong>/** Ad Interaction \*\*/</strong></p><p>- (void)adClicked:(NSString \*)screenId</p><p>- (void)adGratified:(NSString \*)screenId withReward:(double)reward</p> |

**Test Ads**

Application Id : eee33f012ee30473abcda10c65593d97

Security Key : 0adf197193966c9f9c25485154897398

Sample Screen Id for Video : 129fda6f5d8c4f5ea7450ce8b9c94eb8

Sample Screen Id for Interstitial : 3f3d981b416864215563a7ddfecb93f2

Sample Screen Id for Banner : 07d5ffd1766b28cc9b25f99d4b0c22ea

**Debugging**

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.

| **Objective C**                                                                    | **Swift**                                                                     |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| <p>\[PokktDebugger setDebug:\<YES/NO>];</p><p>\[PokktDebugger exportLog:self];</p> | <p>PokktDebugger.setDebug(true/false)</p><p>PokktDebugger.exportLog(self)</p> |

#### **FAQ** <a href="#heading-h.2s8eyo1" id="heading-h.2s8eyo1"></a>

#### If you are using server to server integration with Pokkt, you can also set **Third Party UserId** in PokktAds. <a href="#heading-h.s9e2xv78wi8d" id="heading-h.s9e2xv78wi8d"></a>

| **Objective C**                                   | **Swift**                            |
| ------------------------------------------------- | ------------------------------------ |
| PokktAds.setThirdPartyUserId:(NSString\*) userId; | PokktAds.setThirdPartyUserId(userId) |

#### **GDPR** <a href="#heading-h.1t3h5sf" id="heading-h.1t3h5sf"></a>

#### If you want to set ***GDPR consent*** in Pokkt SDK. **This must be called before calling any ad related API. Developers/Publishers must get the consent from the user.** For more information on GDPR please refer [https://www.eugdpr.org/ ](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. <a href="#heading-h.me51b5lj3sxg" id="heading-h.me51b5lj3sxg"></a>

| **Objective C**                                                                                                                                                                                                                                                   | **Swift**                                                                                                                                                                                                                                                        |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>PokktConsentInfo \*consentInfo = \[\[PokktConsentInfo alloc] init];</p><p>consentInfo.isGDPRApplicable = true;</p><p>consentInfo.isGDPRConsentAvailable = false;</p><p>\[PokktAds setPokktConsentInfo:consentInfo];</p><p>\[PokktAds getPokktConsentInfo];</p> | <p>var consentInfo: PokktConsentInfo!</p><p>consentInfo = PokktConsentInfo()</p><p>consentInfo.isGDPRApplicable = true</p><p>consentInfo.isGDPRConsentAvailable = false</p><p>PokktAds.setPokktConsentInfo(consentInfo)</p><p>PokktAds.getPokktConsentInfo()</p> |

#### **Extra Parameter** <a href="#heading-h.4d34og8" id="heading-h.4d34og8"></a>

#### 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. <a href="#heading-h.a7nzlub58djq" id="heading-h.a7nzlub58djq"></a>

| Objective C                                                                                                                                                                                                                                                                              | Swift                                                                                                                             |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| <p>NSMutableDictionary \*dict = \[\[NSMutableDictionary alloc] initWithCapacity:0];</p><p>\[dict setValue:@"value1" forKey:@"key1"];</p><p>\[dict setValue:@"value2" forKey:@"key2"];</p><p>\[dict setValue:@"value3" forKey:@"key3"];</p><p>\[PokktAds setCallbackExtraParam:dict];</p> | <p>var dict:\[String: Any]=\["key1": "value1", "key2": "value2", "key3": "value3"]</p><p>PokktAds.setCallbackExtraParam(dict)</p> |

* FullScreen Ads are of two types : Video and Interstitial. It can be rewarded or non rewarded. Its properties can be configured from the Pokkt dashboard. You can either cache the ad in advance or directly call show for it. We suggest you cache the ad in advance so as to give seamless play behavior, In other case it will stream the video which may lead to unnecessary buffering delays depending on the network connection.<br>

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

| Objective C                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Swift                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>PokktUserInfo \*pokktUserDetails = \[PokktUserInfo alloc] init];</p><p>pokktUserDetails.name = "";</p><p>pokktUserDetails.age = "";</p><p>pokktUserDetails.sex = "";</p><p>pokktUserDetails.mobileNumber = "";</p><p>pokktUserDetails.emailAddress = "";</p><p>pokktUserDetails.location = "";</p><p>pokktUserDetails.birthday = "";</p><p>pokktUserDetails.maritalStatus = "";</p><p>pokktUserDetails.facebookId = "";</p><p>pokktUserDetails.twitterHandle = "";</p><p>pokktUserDetails.educationInformation = "";</p><p>pokktUserDetails.nationality = "";</p><p>pokktUserDetails.employmentStatus = "";</p><p>pokktUserDetails.maturityRating = "";</p><p>\[PokktAds setUserDetails: pokktUserDetails];</p> | <p>pokktUserDetails = PokktUserInfo()</p><p>pokktUserDetails.name = ""</p><p>pokktUserDetails.age = ""</p><p>pokktUserDetails.sex = ""</p><p>pokktUserDetails.mobileNumber = ""</p><p>pokktUserDetails.location = ""</p><p>pokktUserDetails.birthday = ""</p><p>pokktUserDetails.maritalStatus = ""</p><p>pokktUserDetails.facebookId = ""</p><p>pokktUserDetails.twitterHandle = ""</p><p>pokktUserDetails.educationInformation = ""</p><p>pokktUserDetails.nationality = ""</p><p>pokktUserDetails.employmentStatus = ""</p><p>pokktUserDetails.maturityRating = ""</p><p>PokktAds.setUserDetails(pokktUserDetails)</p> |


---

# 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/pokkt-sdk-integration-guide-v8.2.0-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.
