PhoneGap ios

From POKKT DOCUMENTATION
Jump to: navigation, search

POKKT SDK v6.0.2 Integration Guide for Cordova/PhoneGap (IOS)

Last Update: 28th July, 2017


Download Latest Version Here v6.0.2.


Overview

Thank you for choosing Pokkt SDKfor Cordova. Our Cordova plugin can be used with PhoneGap, Phaser (cocoonjs), Intel XDKand any cordova based framework. This document contains all the information required to set up the SDK with your project. We also support mediation for various third party networks. A separate set of documents is provided for each of these, explaining the implementation process.

Before implementing plugins it is mandatory to go through project configuration and implementation steps, as these sections contain mandatory steps for basic SDK integration and are followed by every plugin.

ScreenName: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.

There is a SampleApp demo app provided with SDK . We will be referencing this app during the course of explanation in this document. We suggest you go through the sample app for better understanding.


Project Configuration

Dependencies

Extract the provided file "PokktCordovaPlugin.zip" into a directory. Execute the following command from your terminal:

$phonegap plugin add /<path-to-plugin-directory>/PokktCordovaPlugin/

Framework

CoreData.framework
Foundation.framework
MediaPlayer.framework
SystemConfiguration.framework
UIKit.framework
CoreTelephony.framework
EventKit.framework
AdSupport.framework
CoreGraphics.framework
CoreMotion.framework
MessageUI.framework
EventKitUI.framework
CoreLocation.framework
AVFoundation.framework
libc++.tbd

Info.plist

Add the below exceptions to your application info.plist.

<key>NSAppTransportSecurity</key>
   <dict>
      <key>NSExceptionDomains</key>
      <dict>
        <key>pokkt.com</key>
        <dict>
           <key>NSIncludesSubdomains</key>
           <true/>
           <key>NSExceptionAllowsInsecureHTTPLoads</key>
           <true/>
           <key>NSExceptionRequiresForwardSecrecy</key>
           <false/>
           <key>NSExceptionMinimumTLSVersion</key>
           <string>TLSv1.2</string>
           <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
           <false/>
           <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
           <true/>
           <key>NSThirdPartyExceptionMinimumTLSVersion</key>
           <string>TLSv1.2</string>
           <key>NSRequiresCertificateTransparency</key>
           <false/>
        </dict>
        <key>cloudfront.net</key>
        <dict>
           <key>NSIncludesSubdomains</key>
           <true/>
           <key>NSExceptionAllowsInsecureHTTPLoads</key>
           <true/>
           <key>NSExceptionRequiresForwardSecrecy</key>
           <false/>
           <key>NSExceptionMinimumTLSVersion</key>
           <string>TLSv1.2</string>
           <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
           <false/>
           <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
           <true/>
           <key>NSThirdPartyExceptionMinimumTLSVersion</key>
           <string>TLSv1.2</string>
           <key>NSRequiresCertificateTransparency</key>
           <false/>
        </dict>
      </dict>
   </dict>

Implementation Steps

SDK Configuration

  1. For all invocation of Pokkt SDK developer will make use of methods available in pokktAds.jsfile using PokktExtension object.
  2. Set Application IdandSecurity key in Pokkt SDK. You can get it from Pokkt dashboard from your account. We generally assign unique application Id and Security key.

    pe = window.plugin.pokktExtension;
    pe.setPokktConfig("<Pokkt Application ID>", "<Pokkt Security Key>");
  3. If you are using server to server integration with Pokkt, you can also set Third Party UserIdin pokktAds.

    pe.setThirdPartyUserId("<Third party user Id>");
  4. When your application is under development and if you want to see Pokkt logs and other informatory messages, you can enable it by setting ShouldDebugto true. Make sure to disable debugging before release.

    pe.setDebug(<true>);

Ad Types

Video
  • Video ad can be rewarded or non-rewarded. You can either cache the ad in advance or directly call show for it.
  • We suggest you to 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.
Rewarded
  1. To cache rewarded ad call:

    pe.cacheRewardedVideoAd("<ScreenName>");
  2. To show rewarded ad call:

    pe.showRewardedVideoAd("<ScreenName>");
  3. You can check if ad is available or not before making c ache or show request for rewarded

    pe.checkRewardedVideoAdAvailability("<ScreenName>",<true / false>);
Non Rewarded
  1. To cache non-rewarded ad call:

    pe.cacheNonRewardedVideoAd("<ScreeName>");
  2. To show non-rewarded ad call:

    pe.showNonRewardedVideoAd("<ScreeName>");
  3. You can check if ad is available or not before making c ache or show request for non rewarded.

    pe.checkNonRewardedVideoAdAvailability("<screen name>", <true / false>);
Interstitial
Rewarded
  1. To cache rewarded ad call:

    pe.cacheRewardedInterstitial("<ScreeName>");
  2. To show rewarded ad call:

    pe.ShowRewardedInterstitial("<ScreeName>");
  3. You can check if ad is available or not before making c ache or show request for rewarded

    pe.checkRewardedInterstitialAvailability("<ScreeName>");
Non Rewarded
  1. To cache non-rewarded ad call:

    pe.cacheNonRewardedInterstitial("<ScreeName>");
  2. To show non-rewarded ad call:

    pe.showNonRewardedInterstitial("<ScreeName>");
  3. You can check if ad is available or not before making c ache or show request for non rewarded

    pe.checkNonRewardedInterstitialAvailability("<ScreeName>");
  1. To load banner ad call:

    pe.loadBanner("<ScreenName>");
  2. To destroy banner ad call:

    pe.destroyBanner(“<ScreenName>");
  3. To disable banner auto refresh call:

    pe.shouldAutoRefresh(false);

Ad Actions

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.

document.addEventListener('AdAvailability', this.handleAdAvailability, false);
document.addEventListener('AdCachingCompleted', this.handleAdCachingCompleted, false);
document.addEventListener('AdCachingFailed', this.handleAdCachingFailed, false);
document.addEventListener('AdDisplayed', this.handleAdDisplayed, false);
document.addEventListener('AdSkipped', this.handleAdSkipped, false);
document.addEventListener('AdCompleted', this.handleAdCompleted, false);
document.addEventListener('AdClosed', this.handleAdClosed, false);
document.addEventListener('AdGratified', this.handleAdGratified, false);
document.addEventListener('AdFailedToShow', this.handleAdShowFailed, false);

Pokkt ad player 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 Teamto do the same for your app through admin console.

Various properties that can be managed through this are:

  1. Back button
    Defines if user is allowed to close the Advertisement by clicking on back button or not.
    Property Name: BackButtonDisabled
    Values:
    True = Back button is disabled and user cannot close the Ad.
    False = Back button is not disabled and user can close the Ad.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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?”.
  7. 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”.
  8. 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”.
  9. 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:SkipTimerMessage
    Values:
    Any String message.
    Default value is “You can skip video in ## seconds”
  10. Incentive message
    Defines message to be shown during video progress, that after what time user will be incentivised.
    Property name:IncentiveMessage
    Values:
    Any String message
    Default value is “more seconds only for your reward !”

User Details

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

var pokktUserDetails = pe.createPokktUserDetails();
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 = "";
pe.setUserDetails(pokktUserDetails);

Debugging

Other than enabling debugging for Pokkt SDK, it can also be used to:

  1. Export log

    Export your log to your desired location, we generally have it in root directory of SD card, if permission for external storage is provided and in cache folder otherwise.

    pe.ExportLog();

Analytics

We support various analytics in Pokkt SDK.
Below is mentioned how to enable various analytics with Pokkt SDK.

Google Analytics
var analyticsDetail = pe.createAnalyticsDetails();
analyticsDetail.selectedAnalyticsType = “GOOGLE_ANALYTICS”;
analyticsDetail.googleAnalyticsID = "Google Analytics Id";
pe.setAnalyticsDetails(analyticsDetail);
Flurry Analytics

Flurry application key can be obtained from Flurry dashboard.

var analyticsDetail = pe.createAnalyticsDetails();
analyticsDetail.selectedAnalyticsType = “FLURRY”;
analyticsDetail.flurryApplicationKey = "flurry Application Key";
pe.setAnalyticsDetails(analyticsDetail);
MixPanel Analytics

MixPanel project token can be obtained from MixPanel dashboard.

var analyticsDetail = pe.createAnalyticsDetails();
analyticsDetail.selectedAnalyticsType = “MIXPANEL”;
analyticsDetail.mixPanelProjectToken = "mixPanel Project Token";
pe.setAnalyticsDetails(analyticsDetail);