VIRE SDK with other ad solutions

In the normal case the ad starts immediately after the ad request was successful. The VIRE ad solution has the advantage that it is ready to combine with other ad solutions. In this case you do not want to start the ad automatically after the ad request. Therefor you can set autoAdStart = false in the AdOptions.

If autoAdStart = false, the callback function will be called twice. First time after the request is executed with the parameters AdResult.HasAd or AdResult.NoAd. If an Ad is available you can call VIRE.startAd() to start the ad manually. After the ad was shown the callback function will be called a second time with the parameter AdResult.Finished or AdResult.Skipped.

The code below shows an example:

using UnityEngine;
using Vire;

public class AdManager : MonoBehaviour
{
    private void Start()
    {
        VIRE.init("3e6d0d66-0a1c-447b-b552-e42611e1d7af");
    }

    public void showAd()
    {
        AdOptions options = new AdOptions { callback = myCallback, autoAdStart = false };
        StartCoroutine(VIRE.requestAd(options));
    }

    private void myCallback(AdResult result)
    {
        switch (result)
        {
            case AdResult.HasAd:
                Debug.Log("Callback - Ad Available.");  
                myStartAd();
                break;
            case AdResult.NoAd:
                Debug.Log("Callback - No ad Available.");
                break;
            case AdResult.Finished:
                Debug.Log("Callback - The ad was successfully shown.");
                break;
            case AdResult.Skipped:
                Debug.Log("Callback - The ad was skipped before reaching the end.");
                break;
            case AdResult.Failed:
                Debug.LogError("Callback - The ad failed to be shown.");
                break;
        }
    }

    private void myStartAd()
    {
       VIRE.startAd();
    }
}

Disable auto manifest post processing

If you do not want to add the required options automatically to your manifest you can add them manually. Therefor you need to delete the folder "Assets/VIRE Plugin/Scripts/BuildPostProcessing". In every vire update the file has to be deleted. Now you have to add the <activity>, <service> and the <permission> to your manifest file by copying them from the code example below.

<manifest>
  <application>

  ...

    <activity android:name="com.vire.vire_library.VIRE_Activity"
              android:screenOrientation="landscape"
              android:hardwareAccelerated="true" />

    <service android:name="com.vire.vire_library.VIRE_Service"
             android:enabled="true"
             android:exported="true" />

  ...

  </application>

  ...

  <uses-permission android:name="android.permission.INTERNET" />

  ...

</manifest>