Skip to content

pubnative/pubnative-corona-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PNLogo

PubNative is an API-based publisher platform dedicated to native advertising which does not require the integration of an SDK. Through PubNative, publishers can request over 20 parameters to enrich their ads and thereby create any number of combinations for unique and truly native ad units.

pubnative-corona-library

pubnative-corona-library is a collection of Open Source tools to implement API based native ads in Corona SDK.

##Contents

Requirements

Corona libraries used by this library:

So, as described in the network library, you will need to add internet permissions to your Android build.settings file

settings =
{
   android =
   {
      usesPermissions =
      {
         "android.permission.INTERNET",
      },
   },
}

Install

  • Download this repository
  • Copy Pubnative folder into your application project root folder (other than the root folder won't work)

Usage

For the usage of the library all required methods are accessed through the pubnative/main.lua module, and in short, these are the basic steps to performa a request and start using the library

So in general, you will need to require the pubnative/main.lua module

local pubnative=require('pubnative.main')

###request.lua ######Methods

  • addParameters(key,value): Adds parameters to the request
  • print(): Prints the currently configured request url
  • cancel(): Cancels current request
  • start(listener): Starts a request with a given listener for callback

In order to create a request and get ads within your application, you will need to create and use a request, that in short steps would be:

  • Create a request
  • Add parameters to it
  • Start the request with a listener
  • Check in the listener for errors or ads
local function adsListener(event)
  if event.error then
    print(event.error)
  else
    -- Ads available in event.ads
  end
end

local function requestAds()
  local request = pubnative.createRequest()
  request.addParameter("app_token","<YOUR_APP_TOKEN>")
  request.addParameter("bundle_id", "<YOUR_BUNDLE_ID>")
  request.addParameter("icon_size", "100x100")
  request.addParameter("banner_size", "1200x627")
  request.addParameter("ad_count", 5)
  request.start(adsListener)
end

Any other parameter can be added as described in the Client API Request, the more parameters you describe, the more info will pubnative server have to serve an accurate ad to your public (increasing revenues).

###model.lua

Once the request is completed you will have a table of ads ready to be used.

######Fields

  • icon: Name of the cached icon_url image in the system.CachesDirectory
  • banner: Name of the cached banner_url image in the system.CachesDirectory
  • data: Hash of fields from the json file as detailed in Client API Response

######Methods

  • open(): Opens the ad in the device browser
  • confirmImpression(): Confirms the impression of the ad within pubnative servers
  • print(): Prints the title of the ad

For further details, please check the provided sample that requests 5 icons and shows them in the screen once a button is pushed.


Misc

License

This code is distributed under the terms and conditions of the MIT license.

Contributing

NB! If you fix a bug you discovered or have development ideas, feel free to make a pull request.