Unity SDK
This page describes how to install the AdGate Media Unity SDK.
Requirements
Unity version 2019.1 and up
1. Install SDK
Download the latest Unity Package Release from the GitHub Releases page.
Double-click on the package or drag the package into your Unity scene to import it.
This SDK depends on the following third-party assets, if you have any of the following in your project please do not re-import them.
JsonDotNet
UniWebView
Click import to complete the SDK installation.
Locate the config file located in
AdGate/Resources/Config/AdGateConfig.asset
. You can turn debug mode on or off depending on your requirements. Debug messages will be completely ignored by the SDK when this is turned off.
2. Using the SDK
To start using the SDK, You need to implement usage of the “AdGate” namespace by adding this above the script:
Now you can use any of the SDK methods.
Load Offer Wall
Parameters:
wallCode
: a string that corresponds to the ID of your offer wall, which you can retrieve from this page.userId
: a string that corresponds to the current user accessing the wallsubIds
: a list of subids you wish to use. They may be any string up to 255 characters long. The available sub ids ares2
,s3
,s4
, ands5
.onOfferWallLoadedSuccess
: A C# delegate action that is called as soon as the offer wall loading succeeded. It does not pass any variable back as it assumes anytime you get this callback, the offerwall loading was successful.onOfferWallLoadingFailed
: A C# delegate action with an error code variable. If this is ever fired, the error code can tell you more about what has happened. You can get more information about the meaning of the codes here.
Example code:
Show Offer Wall
Parameters:
onOfferWallShown
: A C# delegate that is fired once the offer wall has been displayed to the useronOfferWallClosed
: A C# delegate that is fired once the offer wall has been closed by the user
Example code:
Get Latest Conversions
Parameters:
wallCode
: a string that corresponds to the ID of your offer walluserId
: a string that corresponds to the current user accessing the wallsubIds
: a list of subids you wish to use. They may be any string up to 255 characters long. The available sub ids ares2
,s3
,s4
, ands5
.onConversionDetailsAvailable
: A C# delegate action that is called as soon as the offer wall loading succeeded. It does not pass any variable back as it assumes anytime you get this callback, the offerwall loading was successful.onOfferWallLoadingFailed
: A C# delegate action that is called as soon as conversion details are received from the server. It returns a variable ofConversionResponse
type. Here is a sample of the class structure:
If this callback is fired, it is assumed that connection to the server was successful. However, the conversions variable can be null or an empty array if there is no conversion available at the moment the server request was made.
onConversionDetailsFailedToLoad
: A C# delegate action with an error and error code variable. If this is ever fired, the error code can tell you more about what has happened. This would be a standard server error code, while the error message would be any message sent from the server.
Example code:
Example Project
You can view an example project from the SDK github page. In this project you will find sample code on how to use the SDK.
Updating the SDK
Please follow the same installation guide above but remember to untick AdGate/Resources/Config/AdGateConfig.asset from being imported. Otherwise, your config choice will be lost. Please also remember that if you made prior changes to the SDK code, it will be overwritten by the new code.
Last updated