The following steps outline the integration of the Upsight SDK for ad mediation.
First, add the Upsight repository to your application's build.gradle.
Add the following in your application Manifest. The application token and public key are provided on the Upsight Dashboard under Settings > Applications > "YOUR_APPLICATION_NAME".
// Create an UpsightContext from any Android Context.
Tip: You may call Upsight.createContext(android.content.Context) anywhere in your application, and as often as you need a reference to UpsightContext. The same instance will be returned on each call.
Tip: You can use UpsightContext anywhere in your application where you currently use an android.content.Context. It provides extra functionality made available by the Upsight SDK.
mUpsight - The Upsight Context.
quantity - The number of products purchased during the transaction.
currency - The currency as a 3-character ISO 4217 code.
price - The price per unit in local currency.
totalPrice - The total price of the transaction, including fractional amounts of the currency, before store fees have been taken into account.
product - The product ID of the Google Play in-app product.
responseData - The purchase response data from onActivityResult(). See Google Play In-app Billing Version 3 API.
publisherData - Optional custom parameter bundle.
Note If you would like your IAP data to be validated, first upload your Google Play License Key to Upsight Dashboard.
This can be found by navigating to the Upsight Dashboard in the App Settings page. (Applications > YOUR_APPLICATION > App Settings > Edit App > Google Play License Key).
.createBuilder(totalPrice, currency)  // Required event properties.
.setProduct("product.name")           // Optional event property.
.put(customBundle)                    // Custom property bundle.
.put(customKey, customValue)          // Custom property override.
Milestones track user movement through your app and allow you to manage exactly when and where a user sees marketing content, including mediated ads. Milestones are triggered when your user reaches a point in your application that you want to track or take action on.
Milestones have one required property—a "Scope" that uniquely describes that location in your application. Examples of Scope are "main_menu", "inventory", or "level_up".
Displaying marketing content requires a "Billboard". A Billboard is like an empty frame into which the SDK can place content it receives from the server in response to a Milestone. Like Milestone events, each Billboard is associated with a Scope. Upon receiving an event, the server will send marketing content applicable to the Scope of that Milestone, which are eligible for the Billboard with matching Scope. This allows for control of when and where the content is created.
The Billboard created should be destroyed in the onPause() by calling billboard.destroy() to avoid unintended UI transitions. You cannot create two Billboards with the same scope unless the first one has been destroyed, or it has completed the lifecycle of displaying a unit of marketing content, in which case it is unregistered by the system and its handler.onDetach() callback has occurred.
The handler allows the client to be notified of Billboard lifecycle events when an eligible marketing content becomes available. The UpsightBillboardHandlers class provides default implementations, but the client may provide custom implementations by subclassing the defaults, or directly implementing the UpsightBillboard.Handler interface. For example, the client may wish to temporarily disable a Billboard. To accomplish this, return null when handler.onAttach() is called to skip over any marketing content that becomes available during that time.
Additionally, if you would like to check that content is ready to display before opening a billboard, you can use the isContentReady method. This method will only return true if milestone is invoked with the corresponding scope and content has been received from the server.
Tip: The permission requirement android.permission.INTERNET is automatically merged to your application Manifest.
By providing an implementation for this method, your code is given the opportunity to take appropriate action based on your user completing a rewarded video ad.
See below for a sample implementation of the onRewards methods.
// guarantee the current Activity will be present when these callbacks are triggered.
If you would like to validate the reward that the Upsight server has granted to the device, you can do so by sending reward signature data to your server and performing an operation on the contents. You can get the signature data JSON by calling UpsightReward.getSignatureData().