---
agentTools:
  projectIndex: https://developers.appnext.com/llms.txt
---

# Rewarded and Fullscreen Video

Rewarded and Fullscreen Video Unity Plugin

[block:callout]
{
  "type": "warning",
  "title": "Before you begin!",
  "body": "Make sure that you have completed the Unity Plugin installation before you begin integrating the Rewarded/Fullscreen video ad unit"
}
[/block]

[block:api-header]
{
  "title": "Integrating the Rewarded/Fullscreen video ad unit"
}
[/block]

\##Step 1: Initialize the FullScreen / Rewarded
To initialize the FullScreen or the Rewarded video, add the following line to your code:

[block:code]
{
  "codes": [
    {
      "code": "FullscreenVideo fullscreenVideo = new FullscreenVideo(\"<ADD_HERE_YOUR_PLACEMENT_ID>\");\n//Or\nRewardedVideo rewardedVideo = new RewardedVideo(\"<ADD_HERE_YOUR_PLACEMENT_ID>\");",
      "language": "csharp"
    }
  ]
}
[/block]

Make sure to add appnext's namespace

[block:code]
{
  "codes": [
    {
      "code": "\"using appnext;\"",
      "language": "csharp"
    }
  ]
}
[/block]

## Step 4: Caching

To cache an ad, use the following line:

[block:code]
{
  "codes": [
    {
      "code": "fullscreenVideo.loadAd();\n//Or\nrewardedVideo.loadAd();",
      "language": "csharp"
    }
  ]
}
[/block]

## Step 5: Showing the ad

To show the ad, use the following line:

[block:code]
{
  "codes": [
    {
      "code": "fullscreenVideo.showAd();\n//Or\nrewardedVideo.showAd();",
      "language": "csharp"
    }
  ]
}
[/block]

## Step 6 (optional): Delegate

To use delegates add the proper delegate method to the Ad

[block:code]
{
  "codes": [
    {
      "code": "//Fullscreen:\n// Get notified when the ad was loaded:\nfullscreenVideo.onAdLoadedDelegate += onAdLoaded;\n// Get notified when the ad was clicked:\nfullscreenVideo.onAdClickedDelegate += onAdClicked;\n// Get notified when the ad was closed:\nfullscreenVideo.onAdClosedDelegate += onAdClosed;\n// Get notified when an error occurred:\nfullscreenVideo.onAdErrorDelegate += onAdError;\n// Get notified when the ad’s video playing ended:\nfullscreenVideo.onVideoEndedDelegate += onVideoEnded;\n\n//Rewarded:\n// Get notified when the ad was loaded:\nrewardedVideo.onAdLoadedDelegate += onAdLoaded;\n// Get notified when the ad was clicked:\nrewardedVideo.onAdClickedDelegate += onAdClicked;\n// Get notified when the ad was closed:\nrewardedVideo.onAdClosedDelegate += onAdClosed;\n// Get notified when an error occurred:\nrewardedVideo.onAdErrorDelegate += onAdError;\n// Get notified when the ad’s video playing ended:\nrewardedVideo.onVideoEndedDelegate += onVideoEnded;",
      "language": "csharp"
    }
  ]
}
[/block]

The method signature should be:

[block:code]
{
  "codes": [
    {
      "code": "void <name>(Ad ad){..}",
      "language": "csharp"
    }
  ]
}
[/block]

The error delegate signature should be:

[block:code]
{
  "codes": [
    {
      "code": "void <name>(Ad ad, string error){..}",
      "language": "csharp"
    }
  ]
}
[/block]

The video ended delegate signature should be:

[block:code]
{
  "codes": [
    {
      "code": "void <name>(Video ad){..}",
      "language": "csharp"
    }
  ]
}
[/block]

Make sure to remove the delegates if you wish to stop receiving the events or when you dispose

[block:code]
{
  "codes": [
    {
      "code": "fullscreenVideo.onAdLoadedDelegate -= onAdLoaded;\nfullscreenVideo.onAdClickedDelegate -= onAdClicked;\nfullscreenVideo.onAdClosedDelegate -= onAdClosed;\nfullscreenVideo.onAdErrorDelegate -= onAdError;\nfullscreenVideo.onVideoEndedDelegate -= onVideoEnded;",
      "language": "csharp"
    }
  ]
}
[/block]

And for the rewarded unit:

[block:code]
{
  "codes": [
    {
      "code": "rewardedVideo.onAdLoadedDelegate -= onAdLoaded;\nrewardedVideo.onAdClickedDelegate -= onAdClicked;\nrewardedVideo.onAdClosedDelegate -= onAdClosed;\nrewardedVideo.onAdErrorDelegate -= onAdError;\nrewardedVideo.onVideoEndedDelegate -= onVideoEnded;",
      "language": "csharp"
    }
  ]
}
[/block]

## Step 7 (optional): Configure Video FullScreen/Rewarded

In order to change the Fullscreen / Rewarded configuration, call any of the following functions before showing the unit:

[block:code]
{
  "codes": [
    {
      "code": "//Fullscreen:\nfullscreenVideo.setButtonColor(\"#6AB344\");\nfullscreenVideo.setButtonText(\"example\");\nfullscreenVideo.setPostback(\"custom_parameter\");\nfullscreenVideo.setCategories(\"example\");\nfullscreenVideo.setMute(false);\nfullscreenVideo.setProgressType(Video.PROGRESS_CLOCK);\nfullscreenVideo.setProgressColor(\"#ffffff\");\nfullscreenVideo.setVideoLength(Video.VIDEO_LENGTH_LONG);\n//Or\n//fullscreenVideo.setShowClose(true, 5000);\nfullscreenVideo.setOrientation(Ad.ORIENTATION_LANDSCAPE);\n\n//Rewarded:\nrewardedVideo.setButtonColor(\"#6AB344\");\nrewardedVideo.setButtonText(\"example\");\nrewardedVideo.setPostback(\"custom_parameter\");\nrewardedVideo.setCategories(\"example\");\nrewardedVideo.setMute(false);\nrewardedVideo.setProgressType(Video.PROGRESS_CLOCK);\nrewardedVideo.setProgressColor(\"#ffffff\");\nrewardedVideo.setVideoLength(Video.VIDEO_LENGTH_LONG);\n//Or\n//rewardedVideo.setShowClose(true, 5000);\nrewardedVideo.setOrientation(Ad.ORIENTATION_LANDSCAPE);",
      "language": "csharp"
    }
  ]
}
[/block]

## List of configurable options:

**Button Text:**
The install button's text (default is "Install")

**Button Color:**
The install button's color - a 6 hex chars starting with # (default is "#6AB344")

**Category:**
Set preferred ad categories

**Install Postback**:
Postback parameters that will be posted to your server after user installed an app (make sure to encode the values)

**Mute Video:**
Mute the video which is played in the Fullscreen/Rewarded (default is "false")

* true
* false

**Progress Type:**
Choose progress type, or hide it (default is "Video.PROGRESS\_CLOCK")

* Video.PROGRESS\_CLOCK
* Video.PROGRESS\_BAR
* Video.PROGRESS\_NONE

**Progress Color:**
Set progress bar / clock color. 6 characters hex starting with # (default is #ffffff)

**Video Length:**
Set video length - 15 or 30 seconds long (default is VIDEO\_LENGTH\_DEFAULT)

* Video.VIDEO\_LENGTH\_SHORT - Up to 15 seconds long videos
* Video.VIDEO\_LENGTH\_LONG - 20-60 seconds long videos
* Video.VIDEO\_LENGTH\_DEFAULT - Appnext's algorithm priority. Any available video campaign will be served

Please note that if no SHORT type length videos are available, long videos will be served

**Orientation:**
Set the preferred orientation if both landscape and portrait are supported by the application (default is ORIENTATION\_DEFAULT)

* Ad.ORIENTATION\_DEFAULT
* Ad.ORIENTATION\_LANDSCAPE
* Ad.ORIENTATION\_PORTRAIT
* Ad.ORIENTATION\_AUTO

## Step 8: Server-side postback - Rewarded Video ONLY

You can choose to receive server-side postbacks whenever a user finishes watching a video ("video ended" event).
The "video ended" event will serve as a trigger for the reward action.
Please note that in addition to configuring the postback in this integration process, you will also need to set your postback URL on the Appnext Self-Service platform (under the "Apps" page / app "Settings & Placements" / "Advanced Settings').
In order to receive the server-side postback on the "video ended" event, call the following functions before showing the ad:

[block:code]
{
  "codes": [
    {
      "code": "// Transaction ID - make sure to set a unique transaction ID per ad view\n// User ID - pass the User ID so you will know which user to reward\n// Currency Type - type of reward (life / credit / points)\n// Amount - the amount of currency that was rewarded\n// Custom Parameters - pass any custom value / data\nrewardedVideo.setRewardedServerSidePostback(\"TransactionId\", \"UserId\", \"TypeCurrency\", \"Amount\",\"CustomParameter\");",
      "language": "csharp"
    }
  ]
}
[/block]

* Make sure to encode all values passed in each function.
* Passing non null value, for at least one parameter, is mandatory for the reward to be sent.

[block:callout]
{
  "type": "warning",
  "body": "* Each placement has a Placement ID. If you integrate multiple placements, you will need to use a different Placement ID for each.\n* The implementation should be tested on a device and not in a unity simulator.\n* Make sure to use Android Placement IDs in Android project and iOS Placement IDs in iOS project.",
  "title": "Important Note"
}
[/block]

[block:api-header]
{
  "title": "App Categories"
}
[/block]

[block:parameters]
{
  "data": {
    "0-0": "**Android:**\n\n1. Action\n2. Adventure\n3. Arcade\n4. Arcade & Action\n5. Board\n6. Books & Reference\n7. Brain & Puzzle\n8. Business\n9. Card\n10. Cards & Casino\n11. Casino\n12. Casual\n13. Comics\n14. Communications\n15. Education\n16. Educational\n17. Entertainment\n18. Family\n19. Finance\n20. Health & Fitness\n21. Libraries & Demo\n22. Lifestyle\n23. Live Wallpaper\n24. Media & Video\n25. Medical\n26. Music\n27. Music & Audio",
    "0-1": "29. Personalization\n30. Photography\n31. Productivity\n32. Puzzle\n33. Racing\n34. Role Playing\n35. Shopping\n36. Simulation\n37. Social\n38. Sports\n39. Sports Games\n40. Strategy\n41. Tools\n42. Travel & Local\n43. Trivia\n44. Weather\n45. Word\n\n*iOS:**\n\n1. Action\n2. Adventure\n3. Arcade\n4. Board\n5. Books\n6. Business\n7. Card\n8. Casino\n9. Catalogs\n10. Dice",
    "0-2": "11. Education\n12. Educational\n13. Entertainment\n14. Family\n15. Finance\n16. Food & Drink\n17. Graphics & Design\n18. Health & Fitness\n19. Kids\n20. Lifestyle \n21. Medical\n22. Music\n23. Navigation\n24. News\n25. Photo & Video\n26. Productivity\n27. Puzzle\n28. Racing\n29. Reference\n30. Role Playing\n31. Simulation\n32. Social Networking\n33. Sports\n34. Strategy\n35. Travel\n36. Trivia\n37. Utilities\n38. Weather"
  },
  "cols": 3,
  "rows": 1
}
[/block]

Make sure to encode (%20) categories with more than 1 word, example: **Travel**%20%26%20**Local**

[block:api-header]
{
  "title": "Integration Support"
}
[/block]

Should you have any problems integrating the product, log a ticket with us by emailing <support@appnext.com>.