Unity Windows

From POKKT DOCUMENTATION
Jump to: navigation, search

POKKT SDK v4.1 Integration Guide for Unity3d 5.2+ (Windows)

Last Update: July 1st, 2016

Download Latest Version Here v4.1.1.


Overview:

Thank you for choosing Pokkt SDK Plugin v4.1 for Unity3d. Pokkt SDK Video/Interstitial-Ad campaigns feature. This document contains all the information that is needed by you to setup the SDK with your project.

Kindly note that these instructions are for Unity3d Version 5.2 and above, older versions of Unity3d are not supported.

There is a sample app provided with the SDK. We will be referencing this app during the course of explanation in this document. It is suggested that you should check that app to understand the following process in detail.

Note: Please do not copy the code points from this PDF file as it may introduce unwanted characters and space in your code. Instead please refer to sample app source code provided with the sample app.


Configuration Steps:

All we need is the file provided: PokktUnityDemo_Windows.unitypackage

Step 1: Export the content of this package onto your Unity project. The contents of “Plugin/Pokkt” and the “Plugins/Android” directories are mandatory. You can safely ignore all the other stuff, they are provided here to demonstrate the integration of Pokkt-SDK, this document uses snippets from those files.

Step 2: Ensure that you have PWPUnity.dllfile directly inside the Assets/Pluginsfolder. This is the editor’s “placeholder” plugin for the original Windows plugin. Select the PWPUnity.dlland set the following on the Inspector Panel (reference the following image):

Select platforms for plugin: Uncheck “Any Player” and then check only “Editor”

Windows unity1.jpg

Step 3: Next, ensure that you have another PWPUnity.dlland a PWPUnity.pdbinside Assets/Plugins/WSAfolder, along with PokktSDK.dll, PokktSDK.pdband a PokktSDKfolder with some resources (you will use these resources later on). Now select PokktSDK.dlland set the following on the Inspector Panel (reference the following image):

Select platforms for plugin: Check “WSAPlayer”
SDK: PhoneSDK8.1 or Any SDK
CPU: Any CPU
Don’t Process: [CHECK]
Placeholder: [EMPTY]

Windows unity2.jpg

Step 4: Select UnityWindowsExtension.dllinside Assets/Plugins/WSAfolder and set the following on the Inspector Panel (reference the image below):

Select platforms for plugin: Check “WSAPlayer”
SDK: PhoneSDK8.1 or Any SDK
CPU: Any CPU
Don’t Process: [CHECK]
Placeholder: [MAP TO: Assets/Plugins/ PWPUnity.dll]

Windows unity3.jpg

Note: Ignore any exception (System.Reflection.TargetInvocationException) you encounter while importing this DLL file.

Step 5: Once you have built/generated the C# Project, manually add and include the PokktSDK folder inside Assets/Plugins/WSAfolder to the project. This PokktSDKfolder should have a UI folder inside it. Once added to the generated C# Project, select each of the XBF files inside the UI folder and set the following in the Properties Window (reference the image below):

Build Action: Content
Copy to Output Directory: Copy Always

Windows unity4.jpg

This should integrate the Plugin with your project.


3.Implementation Steps

Common:

  1. For all invocation of Pokkt SDK developer will make use of methods available in PokktManager class. This class only have static methods.
  2. Setup your PokktConfig, provide ApplicationId and SecurityKey, these are must for initializing Pokkt.
  3. Once you have you PokktConfigready, invoke InitPokkt method before you invoke any other methods from the PokktManager. This does not apply to session related methods namely StartSessionand EndSessionand few utility methods.
  4. In order to know whether Pokkt is initialized or not, listen to PokktInitialisedEvent, if the provided Boolean parameter is true only then move ahead with other operations.
  5. If you are doing server to server integration with Pokkt you can also set ThirdPartyUserIdin PokktConfig.
  6. While in development, you can call PokktManager.SetDebug(true) to see Pokkt debug logs and toast messages. please make sure to change this to false for production build.
  7. Call PokktManager.NotifyAppInstall() to log your application installation information with Pokkt.
  8. Call PokktManager.TrackIAP(details) to log any in-app purchase details with Pokkt.

Session:

  1. Invoke PokktManager.StartSession() at the start of his application and once only.
  2. You should call PokktManager.EndSession()at the end of his application and once only.

Rewarded/Non-Rewarded Ads:

  1. You will have to configure an AdConfig object to request for any ad to be displayed. It also provides options for customizing your ad-screen. It is recommended to have different AdConfig objects for each screens. Followings are the values that you can set with AdConfig:
    • ScreenName (Required): This controls the placement of ads and can be created on Pokkt Dashboard.
    • IsRewarded (Required):Requested ad type. Ad gratification will happen only for rewarded ads.
    • BackButtonDisabled: Disable ‘back’ button press while on ad-screen.
    • DefaultSkipTime:If ad-skipping is allowed, this provides the seconds it will wait before the skip button appears.
    • ShouldAllowSkip: Whether skipping-ad is allowed or not. If set to ‘false’, user will be forced to watch the ad till it finishes.
    • ShouldAllowMute: Whether to allow sound-mute while on ad-screen, it controls the ‘mute’ button. Cannot contains whitespaces and only special characters allowed are hyphens (-) and underscores (_).
    • ShouldConfirmSkip: Controls whether to show the skip-confirmation dialog box. If set to ‘false’, the ad will be silently closed without prompting for confirmation
    • SkipConfirmMessage:The message that will appear on skip-confirmation dialog box.
    • SkipConfirmYesLabel: ‘Yes’ Label of skip-confirmation dialog box.
    • SkipConfirmNoLabel:‘No’ Label of skip-confirmation dialog box.
    • SkipTimerMessage:The message on countdown-timer before the skip button appears. The message must contain a ‘##’-placeholder to show timer value.
    • IncentiveMessage:If set, the message will be displayed while prompting user to watch the ad for certain time before it can be rewarded.
  2. Invoke PokktManager.CacheAd(adConfig)to cache the ad on device. Cached-ads provide better user experience than streaming-ads
  3. You can call PokktManager.CheckAdAvailability(adConfig)to check if the adcampaigns are available or not. The result will be notified via AdAvailabilityEvent.
  4. Invoke PokktManager.ShowAd(adConfig)to show ad.
  5. Following are ad-related events, you can refer to the provided sample-code to understand the ideal implementation on how to consume these:
    • AdCachingCompletedEvent
    • AdCachingFailedEvent
    • AdDisplayedEvent
    • AdSkippedEvent
    • AdCompletedEvent
    • AdClosedEvent
    • AdGratifiedEvent
    • AdAvailabilityEvent
  6. Reward user ONLY from the AdGratifiedEvent.

Export Logs (Only for Windows Phone Plugin):

  1. Call PokktManager.ExportLog()to export the Pokkt SDK logs to folder of your choice.
  2. This API shows a folder chooser dialog where user can choose a particular folder.
  3. User can also create a new folder where user wants to export the logs.
  4. You will also have to modify the exported Visual Studio Project and locate the App.xaml.cs file. Then find the method called OnActivated(create one if not there). Next call PokktNativeExtension.OnAppActivated(param).This ensures log file export.

    protected override void OnActivated(IActivatedEventArgs args)
    {
       PokktNativeExtension.OnAppActivated(args);
       // some other stuff
    }

Clearing Log File:

You can call PokktNativeExtension.ClearLogFile()to clear the log file.

Optional Parameters:

PokktConfigalso has provision for developers to provide extra user data available with them to Pokkt. We currently support following data points: Name, Age, Sex, MobileNo, EmailAddress, Location, Birthday, MaritalStatus, FacebookId, TwitterHandle, Education, Nationality, Employmentand MaturityRating.