PubNative Android Plugin for Corona supports 2 ad formats:
Please follow this integration guide to configure PubNative ads.
Requirements
- Corona SDK project. - You should have already configured a Corona project. You can find how to do this at here
- PubNative Android SDK
- PubNative Corona Plugin
- An App Token provided in PubNative Dashboard.
- A Placement Name configured and obtained from the PubNative Dashboard
Permissions
The following permissions must be added to the manifest of the Android app that will contain the plugin:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_COARSE_LOCATION (Optional)
Corona Banner Plugin Integration
Requirements
- Corona SDK project (You should already have a configured Corona project. You can find how to do this at https://docs.coronalabs.com/guide)
- Android Project min API >= 15
- An App Token provided in PubNative Dashboard
- A Placement Name configured in the PubNative Dashboard as Small Layout
- Permissions for Android project:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_COARSE_LOCATION (Optional)
Installation
Download JAR file
You can download already prepared JAR file, which contain plugin classes inside, from https://github.com/pubnative/pubnative-corona-sdk/tree/master/banner/plugins/2017.3115/android
Clone Banner module from GitHub
If you don't want to use JAR files, we already have example of Corona Application at GitHub and you can simply use it for your app. For this clone project from https://github.com/pubnative/pubnative-corona-sdk/tree/master/demo/android and put it into your Corona Android app folder:
<YOUR_CORONA_APP_PROJECT>/android/
Note: If you already have a fully functional Android app, better clone our app to separated folder and import banner module from it.
Add JAR to the Android project
If you are using JAR file, copy it file to libs
folder inside of Corona android project:
<YOUR_CORONA_APP_PROJECT>/android/app/libs
and add the following line into your gradle build file:
compile fileTree(include: ['*.jar'], dir: 'libs')
Include JAR dependencies
Add the Banner Plugin dependencies into your Corona Android gradle file:
compile 'net.pubnative:player:2.0.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'net.pubnative:url_driller:1.3.4'
Using
Now you can include plugin into Lua by
local banner = require( "plugin.pubnative.banner" )
This will allow you use plugin inside of Lua code.
Plugin has a three main methods:
load("<APP_TOKEN>", "<PLACEMENT>", listener)
Load Banner data in background. listener this is a function which called from Banner when it's loaded.
show()
Method show banner on the screen.
hide()
Method hide banner from the screen.
And has four helper methods (Should be called before show()):
setBannerPositionTop()
Method set position for the Banner to TOP.
setBannerPositionBottom()
Method set position for the Banner to BOTTOM.
setImpressionListener(listener)
Optional. If you wants to know when impression for banner will be detected, you can use this method. listener - function, which will be called from Banner Plugin
setClickListener(listener)
Optional. If you wants to know when click for banner will be detected, you can use this method. listener - function, which will be called from Banner Plugin
Corona Interstitial Plugin Integration
Requirements
- Corona SDK project (You should already have a configured Corona project. You can find how to do this at https://docs.coronalabs.com/guide)
- Android Project min API >= 15
- An App Token provided in PubNative Dashboard
- A Placement Name configured in the PubNative Dashboard as Large Layout
- Permissions for Android project:
android.permission.INTERNET
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_COARSE_LOCATION (Optional)
Installation
Download JAR file
You can download already prepared JAR file, which contain plugin classes inside, from https://github.com/pubnative/pubnative-corona-sdk/tree/master/interstitial/plugins/2017.3115/android
Clone Interstitial module from GitHub
If you don't want to use JAR files, we already have example of Corona Application at GitHub and you can simply use it for your app. For this clone project from https://github.com/pubnative/pubnative-corona-sdk/tree/master/demo/android and put it into your Corona Android app folder:
<YOUR_CORONA_APP_PROJECT>/android/
Note: If you already have a fully functional Android app, better clone our app to separated folder and import interstitial module from it.
Add JAR to the Android project
If you are using JAR file, copy it file to libs
folder inside of Corona android project:
<YOUR_CORONA_APP_PROJECT>/android/app/libs
and add the following line into your gradle build file:
compile fileTree(include: ['*.jar'], dir: 'libs')
Include JAR dependencies
Add the Interstitial Plugin dependencies into your Corona Android gradle file:
compile 'net.pubnative:player:2.0.1'
compile 'com.google.code.gson:gson:2.8.1'
compile 'net.pubnative:url_driller:1.3.4'
This is necessary or Plugin will not work.
Using
Now you can include plugin into Lua by
local interstitial = require( "plugin.pubnative.interstitial" )
This will allow you use plugin inside of Lua code.
Plugin has a three main methods:
load("<APP_TOKEN>", "<PLACEMENT>", listener)
Load Banner data in background. listener this is a function which called from Banner when it's loaded.
show()
Method show banner on the screen.
hide()
Method hide banner from the screen. Normally, Interstitial will hide automatically after click on it.
And has four helper methods (Should be called before show()):
setShowListener(listener)
Optional. If you wants to know when interstitial shown, you can use this method. listener - function, which will be called from Interstitial Plugin
setHideListener(listener)
Optional. If you wants to know when interstitial hidden, you can use this method. listener - function, which will be called from Interstitial Plugin
setImpressionListener(listener)
Optional. If you wants to know when impression for banner will be detected, you can use this method. listener - function, which will be called from Interstitial Plugin
setClickListener(listener)
Optional. If you wants to know when click for banner will be detected, you can use this method. listener - function, which will be called from Interstitial Plugin