Difference between revisions of "PhoneGap Android"

Jump to: navigation, search
(Non Rewarded)
Line 138: Line 138:
==== Interstitial ====
==== Interstitial ====

Revision as of 07:52, 2 May 2017

POKKT SDK v6.0 Integration Guide for Cordova/PhoneGap (Android)

Last Update: 27th March, 2017

Download Latest Version Here with PDF Documentation v6.0.


Thank you for choosing Pokkt SDKfor PhoneGap. This document contains all the information required to set up the SDK with your project. We also support mediation for various third party networks. To know the supported third party networks and their integration process go to plugins section .

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.

minSdkVersionsupported is 11 .

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 SampleAppdemo 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


To install Pokkt’s plugin for cordova execute the following command from your terminal to install directly from the npm

$cordova plugin add cordova-plugin-pokkt@6.0.0

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

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

We expect Google play servicesintegrated in project, although it;s optional but we recommend you to integrate it, as it’s required to fetch AdvertisingIDfor device,which is useful to deliver targeted advertising to Android users.


Permissions Declarations

We have added the following permissions to the manifest

  1. Mandatory permissions.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    • android.permission.INTERNET = Required for SDK communication with server.
    • android.permission.READ_PHONE_STATE = Required for creating unique identifier for you application based on the unique id of the device like IMEI.
  2. Optional permissions.

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    • android.permission.ACCESS_NETWORK_STATE = Required to detect changes in network, like if WIFI is available or not.
    • android.permission.ACCESS_WIFI_STATE = Required to detect changes in network, like if WIFI is available or not.
    • android.permission.CHANGE_WIFI_STATE = Required to detect changes in network, like if WIFI is available or not.
    • android.permission.WAKE_LOCK = Required to prevent device from going into the sleep mode during video play.
    • android.permission.WRITE_EXTERNAL_STORAGE = Required to store media files related to ads in external SD card, if not provided we will use app cache folder to store media files, which will result in unnecessary increase in application’s size. It is recommended to ask for this permission as low end devices generally have less internally memory available.
    • android.permission.WRITE_CALENDAR = Some Ads create events in calendar.
    • android.permission.ACCESS_COARSE_LOCATION" = Some Ads show content based on user’s location.
    • android.permission.ACCESS_FINE_LOCATION = Some Ads show content based on user’s location.
    • android.permission.CALL_PHONE = Some Ads are interactive and they provide you a way to call directly from the content.
    • android.permission.SEND_SMS = Some Ads are interactive and they provide you a way to send message.
Activity Declaration

Add the following activity in your AndroidManifest for Pokkt SDK integration.

   android:windowSoftInputMode="stateAlwaysHidden|adjustUnspecified" />

You can change the android:screenOrientation="landscape"to of your choice, the way you want to display the ads.

Service Declaration

We have added the following service in your AndroidManifest for receiving InApp notifications.

   android:label="PokktNotificationService" />

Implementation Steps

SDK Configuration

  1. For all invocation of Pokkt SDK developer will make use of methods available in pokktAds.jsfile using PokktExtensionobject.
  2. Set Application Idand Security keyin 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.


Ad Types

  • 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.
  1. To cache rewarded ad call:

  2. To show rewarded ad call:

  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:

  2. To show non-rewarded ad call:

  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>);


  1. To cache rewarded ad call:

  2. To show rewarded ad call:

  3. You can check if ad is available or not before making c ache or show request for rewarded

Non Rewarded
  1. To cache non-rewarded ad call:

  2. To show non-rewarded ad call:

  3. You can check if ad is available or not before making c ache or show request for non rewarded


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
    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
    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
    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
    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
    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
    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
    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
    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
    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
    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 = "";


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.

  2. Export log to cloud

    You can also export log to cloud.



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";
Flurry Analytics

Flurry application key can be obtained from Flurry dashboard.

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

MixPanel project token can be obtained from MixPanel dashboard.

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

Pokkt Dashboard

InApp Notifications

Open developer dashboard -> Manage App -> Notifications

Create notifications
  1. Basic notification information required.


    1. Name:

      A friendly name for notification. It will help you to distinguish between different notifications.

    2. App:

      Select your app for which you want to assign notifications.

    3. Platform:

      Select OS platform for which you want to target notifications.

    4. Countries:

      Select countries where this notifications will be shown to users. Let’s say if you have users in multiple countries, you can selectively target notifications to them.

    5. App version:

      Enter your app version for which you want to show notifications. Let’s say you have multiple version installed among users and you want to send different notifications to different users based on their versions.

    6. Last seen:

      Set minimum and maximum limit in days for which user can remain away from the app.
      Let’s say if min = 2 and max = 4, and user hasn’t open your app for atleast 2 days, you can remind by showing notification, but if 4 days have passed app will not show any more notifications to user.

    7. Message:

      Message you want to show in notifications bar.

    8. Title:

      Title for the notification to be shown in notification bar.


  2. Schedule notification
    1. Daily


    2. Weekly


    3. Monthly