Google PAL
The fl-ads-pal library integrates with Google PAL library to enable publishers make a direct call to monetize Android Applications.
Create Configuration
Create a PALSessionConfiguration
with the configuration which is needed. The following snippet shows configuration creation with sample configuration values.
val palConfig = PALConfiguration(
willAdAutoPlay = true,
descriptionUrl = URL(contentURL),
iconsSupported = false,
omidPartnerName = "Appname",
omidPartnerVersion = "",
omidVersion = "",
playerType = "FL PLayer",
playerVersion = PlayerLibraryInfo.VERSION,
ppid = "some id"
)
PALConfiguration properties
Property | Type | Description |
---|---|---|
willAdAutoPlay | Boolean | Defines whether the ad will be auto played without waiting for user interaction or not. |
willAdPlayMuted | Boolean | Defines whether the ad will be played while muted or not. |
continuousPlayback | Boolean | Defines whether the player intends to continuously play the content videos one after another similar to TV broadcast or video playlist. |
descriptionUrl | URL | Defines the description URL of the content during which the ad will be played. |
iconsSupported | Boolean | Defines whether VAST icons are supported by the video player. |
nonceLengthLimit | Int | Defines the length limit of the generated nonce. |
omidPartnerName | String | The name of the partner integrating OMID measurement. |
omidPartnerVersion | String | The version of the partner integrating OMID measurement. |
omidVersion | String | The version of OMID that the player responsible for ad playback integrates with. |
playerType | String | The partner provided player type. |
playerVersion | String | The partner provided player version. |
ppid | String | The publisher provided ID. |
videoHeight | Int | The height of the ad video element. |
videoWidth | Int | The width of the ad video element. |
Create PAL Session
Create a PALSession
for every playback. The events for the playback can be captured through this session.
val palSession = PALFactory.createPALSession(
context,
palConfiguration,
allowStorage = false,
logger
)
Get Nonce
In order to get the Nonce from Google PAL you need to call the method initialize
from the PALSession
instance, and the callback function that will be used to return the value of Nonce once Google PAL return it.
val nonce = palSession.initialize()
when (nonce) {
is Result.Failure -> {
logger.error("Failed to fetch Google PAl nonce: ${nonce.value}")
}
is Result.Success -> {
logger.info("Google PAL nonce generated successfully: ${nonce.value}")
}
}
Session Events
Trigger the following events to notify the playback events to PALSession
Send Playback Start
In order to notify to Google server that playback is started you need to call the method sendPlaybackStart
without any parameters.
palSession.sendPlaybackStart()
Send Playback End
In order to notify to Google server that playback is ended you need to call the method sendPlaybackEnd
without any parameters.
palSession.sendPlaybackEnd()
Send Click
In order to notify to Google server that ad playback is clicked you need to call the method sendClick
without any parameters.
palSession.sendClick()
Send Gestures
In order to notify to Google server about any touch interaction with the player, you need to call the method onVideoViewTouch
.
palSession.onVideoViewTouch(motionEvent)