Unity SDK

144 views 15/02/2018 Shay Karpeles 0

Getting Started

This document details the process of integrating YouAppi’s SDK with your Unity app.

If you have any question you can email us to: support@youappi.com

Requirements:

  • Android: Minimum API level: 9, Android 2.3
  • iOS:
    • XCode 7+ (Swift 3.2+, Objective C).
    • iOS 8.0+ target deployment.
    • armv7, arm64 devices, and the simulator.

Download YouAppi’s Unity SDK

Unity latest SDK version can be downloaded as a ZIP file from the following URL:

Unity SDK

The ZIP file contains:

  • SDK unity package – youappi.unitypackage
  • Sample app – youAPPiUnitySample

Import YouAppi Package

  • Open the Unity project you would like to integrate with YouAppi SDK.
  • Go to Assets → Import Package → Custom Package

  • Select youappi.unitypackage from its location on disk.
  • A dialog will be opened showing the package contents.
  • Make sure all assets are selected and press import copy the content of the package to your project.

Using YouApi SDK on your project

Example is shown for rewarded ad unit, but behavior is the same for all ad units.

Create YouAppi instance an initialize it:

public class Tests : MonoBehaviour
{
    private YouAppi youAppi;
    private YARewardedVideoAd rewardedVideoAd;
 
    void Start ()  {
        this.youAppi = new YouAppi();
        Debug.Log ("Access Token is: " + this.youAppi.accessToken);
    }
}

Create a rewarded video instance, load an ad and show it when it is ready:

public void showRewardedVideoAd() {
    this.rewardedVideoAd = this.youAppi.rewardedVideo("RewardedVideoAdUnitId");
    this.rewardedVideoAd.LoadSuccess += (sender, AdUnitEventArg) => {
        this.rewardedVideoAd.show();
    };
 
    this.rewardedVideoAd.load();
}

Build project for Android

  • Go to File → Build Settings…

  • Choose Android from the left list.
  • Change Build System to Gradle (New).
  • Check Export Project.
  • Check Development Build.

  • Press Export and select the folder on which the Android project will be created.

Build for iOS

  • Go to File → Build Settings…

  • Choose iOS from the left list.

  • Press Export and select the folder on which the iOS project will be created.
  • Add the YouAppi.framework to General → Embedded Binaries
  • Change to YES inside the build settings under the option ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES.
  • Change to YES inside the build settings under the option DEFINES_MODULE.

Load and Show best practices

  • Make sure to init the SDK as soon as the app starts. It might take few seconds to complete the init process.
  • Make sure to load the ad about 30 seconds before you want to show it, since it takes time for the ad and assets to be prepared.
  • make Make sure to show an ad as close as possible to loading an ad, in order to have a better fill rate and relevant ads.
  • Make sure not to wait too long before showing an ad, since it can be expired by the time you show it (expiry time is 5 hours).
  • Use ad event listeners in order to be notified when an ad is ready to be shown.
  • Use ad event listeners to handle load and show.
  • Loading an ad too many times without showing it might cause YouAppi servers to block the SDK from requests.