Vserv Windows Phone 8.1 (XAML) Vmax SDK V 3: Version 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

VservWindows

Phone8.1(XAML)
VMAXSDK
v3

Version3

Contents
Introduction
Prerequisites
DownloadtheSDK
IntegratingtheVMAXSDK
RequestingAds
Initializingthe
VservAdView
RequestingInterstitials
ManagedInterstitialsusingLoadAd()
Settingarequesttimeout
RequestingBannerAds
ManagedBannerAdsusingLoadAd()
SettingRefreshRate
Optional
Callbacks
DidCacheAd
Callback
DidLoadAd
Callback
FailedToLoadAd
Callback
FailedToCacheAdCallback
WillPresentOverlay
Callback
WillDismissOverlay
Callback
WillLeaveApp
Callback
TestingIntegration
SettingTestDevice
UsingtheTestZones

Mediation
Queries

Version3

Introduction
TheVservVMAXSDKisdesignedtohelpyouintegrateAdsinyourapplicationandfasttrackyourwayto
monetizingyourWP8.1(XAML)applications.

Prerequisites
Beforeyoubegin,weneedtomakesureofafewthings:

1. YouhaveaVserv.mobiDeveloperAccount.Ifyouhaveone,gotoStep2.Ifyoudonot,signupat
our

DeveloperPortal
.
2. Notedownyour
ZoneID
.ThiswillberequiredlateronwhenyouusetheVMAXSDKtorequestAds.
ThedefaultZoneIDwillbeavailableinyourwelcomeemailoryoucouldvisit
https://admin.vserv.mobi/admin/affiliatezones.php
togetalistofallyourzones.

DownloadtheSDK
ThefirststepforintegratingVMAXSDKinyourWP8.1(XAML)applicationistodownloadourSDK
package.TheSDKpackageisavailablefrom

here
.

AlternativelytheSDKcanalsobedownloadedasNuGetpackageusingthefollowingcommandintheNuget
PackageManager.

InstallPackage
com.vserv.windows.ads.wp81

Note*:

IncaseyoudownloadtheNugetPackage,the
com.vserv.windows.ads.wp81.dll
willbeautomaticallyrefferedin
the
References
section.Deletethatandaddareferencetothedllwhichwillbepresentinthedownloadedpackagesfrom
Nugetatthisposition
..\packages\com.vserv.windows.ads.wp81.3.0.1.1\lib\wpa81.[Donotreferthedllwhichisinside
thefolderhavingthesamenameasofdll.]

WesuggestthatyouunziptheSDKZipfilethatyoujustdownloadedintoatemporaryfolder.Assumingthat
thefolderis
[VMAX_SDK_FOLDER]
,youwillseethefollowingcontents:

VMAXSDKWP81/packages ThisfoldercontainstheVMAXSDKandits
dependencies.
VMAXSampleAppWP81
/

SampleWP8.1projectsourcecodethatdemonstrates
VMAXSDKintegration.

IntegratingtheVMAXSDK

Version3

Beforeyoustartyouneedtomakesurethatyourprojectsatisfiesthefollowingrequirements:

1. Youneedtocopythe
packages
folderintoyourprojectsfolderstructureandthenaddthe
com.vserv.windows.ads.wp81.dll
toyourproject[Project>AddReference>Browse]whichwill
bepresentinthe
packages
folder.

2.
YoualsoneedtomakesurethatyourprojecthasthefollowingcapabilitiesinPackage.appxmanifest
:

internetClientServer
musicLibrary
picturesLibrary
videosLibrary
appointments
location

YoucanthenreferencetheVservVMAXlibraryinyourcodebyusingthefollowingusingdirective

ThroughcodebehindinC#
usingcom.vserv.windows.ads.wp81
usingcom.vserv.windows.ads

ThroughXAML
TointegratetheVservAdViewthroughXAMLyouhavetofirstimportthenamespaceinwhichisdeclared.
Todothat,copythisstatementtothestartingofyourXAMLpagewhereotherXAMLnamespacesare
declared.
xmlns:ad="using:com.vserv.windows.ads.wp81"

RequestingVservAds
TheVMAXSDKprovidesyouwithvariousmechanismstorequestforAdsinyourWP8.1(XAML)
application.TheSDKprovidesbothsimplefullymanagedAdrequestmethodsandalsotheCache&Show
Admethodstoenableprefetchingofadsandshowingthemlater.

RequestingInterstitials
ManagedInterstitialsusingLoadAd()
Torequestaninterstitialyouneedtocallthe
LoadAd()
method.Hereisanexample

VservAdViewadView=newVservAdView()
adView.UX=VservAdUX.Interstitial
//TospecifyexplicitlythatyouwanttodisplayInterstitialads
adView.ZoneId=<zoneid>
//Thiswillsetthezonefromwhereadswillbefetched.
adView.TimeOut=20
//
TosettimeoutifAdfailedtofetch.

Version3

TosetDemographicparameters(optional),

adView.UserInfo.Age=<age>
//Tosetageofuser
adView.UserInfo.City=<city>
//Tosetcityofuser
adView.UserInfo.Country=<country>
//Tosetcountryofuser
adView.UserInfo.DOB=<dob>
//Tosetdateofbirthofuser
adView.UserInfo.Email=<email>
//Tosetemailofuser
adView.UserInfo.Gender=<gender>
//Tosetgenderofuser
adView.LoadAd()
//
ThiswillloadtheAdandonsuccessprovidesacallBacknamed
DidLoadAd
.You
needtohandlethistoperformanyactiononthiseventinyourapplication.

InterstitialCaching
ToCacheInterstitialAdsandshowingthemlaterwillbepossiblethroughbelowapi:

adView.CacheAd()

//
ThiswillcacheAdandsenditrespectivecallback.Ifcachedsuccessfullyitwill
givethecallBack
DidCacheAd
.Youneedtohandlethistoperformanyactiononthiseventinyour
application.

ShowingCachedAds
:
adView.ShowAd()

//
ThiswillshowCachedAd

CancelAds:
adView.CancelAd()
//
ThiswillcancelCacheAdandfreeupallresourcesofadview.

RequestingBannerAds
ManagedBannerAdsusingLoadAd()
YoucanrequestforBannerAdswhichautorefreshautomaticallyinaspecificcontainerusingLoadAd()
method.Thesignatureforthemethodisshownbelow:

VservAdViewadView=newVservAdView()
//ThiswillinitializetheVservAdView
//NowyoucansetthepropertiesandconfiguretheadView
adView.ZoneId=<yourzoneid>
//enteryour<zoneid>here
adView.UX=VservAdUX.Inline
//forinlineads

adView.TimeOut=20
//
TosettimeoutifAdfailedtofetch.
adView.RefreshRate=refreshRate

//
TosetrefreshrateforbannerAds
adView.Refresh=true

//
Toenablerefreshofbannerstrue/false

(optional)
adView.PauseRefresh()

//
Toresumerefresh
adView.StopRefresh()

//
Tostoprefresh
adView.PauseRefresh()

//
ToPauserefresh

TosetDemographicparameters(optional):

adView.UserInfo.Age=<age>
//Tosetageofuser

Version3

adView.UserInfo.City=<city>
//Tosetcityofuser
adView.UserInfo.Country=<country>
//Tosetcountryofuser
adView.UserInfo.DOB=<dob>
//Tosetdateofbirthofuser
adView.UserInfo.Email=<email>
//Tosetemailofuser
adView.UserInfo.Gender=<gender>
//Tosetgenderofuser

OptionalCallbacks
TheVservAdViewgivescallbacksrespectivelyonsuccessfulandunsuccessfulfetchingattemptsofAdsas
wellasbasedoninteractionswiththeads.

FailedToLoadAdCallback
AttimeswemightnotbeabletoserveanAdtoyou,inwhichcasetheVMAXSDKprovidesthefollowing
callBack.Thiswillcallhandlerattachedtoit.

privatevoidAdFailed(objectsender,com.vserv.windows.ads.wp8.VservAdView
.AdFailedEventArgse)
{
//..handlercodegoeshere
}

FailedToCacheAdCallback
AttimeswemightnotbeabletoserveanAdtoyou,inwhichcasetheVMAXSDKprovidesthefollowing
callBack.Thiswillcallhandlerattachedtoit.
privatevoidDidFailed_CacheAd(objectsender,EventArgse)
{
//handlercodegoeshere
}

DidLoadAdCallback
ThisCallbackmethodisinvokedwhenfetchedAdissuccessfullyrendered.
privatevoidAdReceived(objectsender,EventArgse)
{
//..handlercodegoeshere
}

DidCacheAdCallback
ThisCallbackmethodisinvokedwhenAdiscachedsuccessfully.

Version3

privatevoidAdCached(objectsender,EventArgse)
{
//..handlercodegoeshere
}

WillDismissOverlayCallback

ThisCallbackmethodisinvokedwhenAdisdismissed.

privatevoidAdCollapsed(objectsender,EventArgse)
{
//..handlercodegoeshere
}

WillLeaveAppCallback
ThisCallbackmethodisinvokedWhenAdisgoingtoleavecurrentAppandopenanyoutsideApp.
privatevoidLeavingApplication(objectsender,EventArgse)
{
//..handlercodegoeshere
}

WillPresentOverlayCallback
ThisCallbackmethodisinvokedwhenAdisgoingtobeshown.
privatevoidAdExpanded(objectsender,EventArgse)
{
//..handlercodegoeshere
}

TestingIntegration

TheVservSDKIntegrationcanbetestedbyeithersettingyourintegrationtotestmodeforcertaindevices
orbyusingtheTestZonesprovidedbyVserv.

AddingTestDevices
TheVservSDKallowsyoutosetanumberofDevicesasTestDevicesbypassingtheirAdvertisingIdtothe
SDK.Youcanaddtestdevicesusingthe
TestDevice
propertywhichtakesalistofid(string)asits
parameters.

adView.TestDevice=newList<string>(){[youradvertisingid/idshere]}

Version3

EachDevicesAdvertisingIDcanbefetchedbyusingthefollowingpieceofcodeinyourapplication.

try
{
varadvertisingIdToPrint=
Windows.System.UserProfile.AdvertisingManager.AdvertisingId
}
catch{}

UsingtheTestZones
YoucanalsotestyourintegrationacrossoursolutionsbyusingthefollowingZoneIDs.

BillboardTestZoneID:
8063
BannerTestZoneID:
20846

Note:PleasemakesureyourproductionAppdoesnothavetheseZonesasyouwouldnotbeearning
revenueusingtheseZones.

Mediation
ToSupportMediationwithpartners:

1.) Addreferenceto
com.vserv.windows.ads.wp81.dll

inyour
project.Itconsistsofallsupported
ClienttoServerintegrationPartnerslike
Microsoft,AdDuplex
.
2.) FillrequireddetailsonVservwebinterfacetostartmediationforthatzone.

Queries

IfyouhaveanyQueriesorissuespleaseemailusatdevelopers@vserv.mobi.

Version3

You might also like