Skip to main content

iOS

  1. Create empty Unity project (used version is 2021.3.18)
  2. Download Unity package SA 8.5.3 (higher versions will probably work)
  3. Download SuperAwesomeiOS.zip (will be required later)
  4. Import package in Unity
  5. Copy paste MainScript.cs (script is a tweaked version of the one from their tutorial) Interstitials tutorial
    using tv.superawesome.sdk.publisher;
    using UnityEngine;
    
    public class MainScript : MonoBehaviour
    {
        private const int PlacementId = 53856;//30473
    
        private void Awake()
        {
            AwesomeAds.init(true);
        }
    
        private void Start()
        {
            // set configuration production
            SAInterstitialAd.setConfigurationProduction();
    
            // to display test ads
            SAInterstitialAd.enableTestMode();
    
            // lock orientation to portrait or landscape
            SAInterstitialAd.setOrientationPortrait();
    
            // enable or disable the android back button
            SAInterstitialAd.enableBackButton();
    
            //set callbacks so we play an ad only after it's loaded
            SetCallbacks();
        }
    
        public void PlayInterstitial()
        {
            // start loading ad data for a placement
            SAInterstitialAd.load(PlacementId);
    
            Debug.Log("Try to play ad...");
        }
    
        private void SetCallbacks()
        {
            SAInterstitialAd.setCallback(SAInterstialAd_OnCallback);
        }
    
        private void SAInterstialAd_OnCallback(int placementId, SAEvent eventType)
        {
            Debug.Log($"Handling Interstitial callback for id {placementId}...");
    
            switch (eventType)
            {
                case SAEvent.adLoaded:
                    // called when an ad has finished loading
                    Debug.Log("Ad loaded callback...");
                    SAInterstitialAd.play(PlacementId);
                    break;
    
                case SAEvent.adEmpty:
                    // called when the request was successful but the server returned no ad
                    Debug.LogWarning("Ad empty callback...");
                    break;
    
                case SAEvent.adFailedToLoad:
                    // called when an ad could not be loaded
                    Debug.LogWarning("Ad failed to load callback...");
                    break;
    
                case SAEvent.adShown:
                    // called when an ad is first shown
                    Debug.Log("Ad shown callback...");
                    break;
    
                case SAEvent.adFailedToShow:
                    // called when an ad fails to show
                    Debug.LogWarning("Ad failed to show callback...");
                    break;
    
                case SAEvent.adClicked:
                    // called when an ad is clicked
                    Debug.Log("Ad clicked callback...");
                    break;
    
                case SAEvent.adEnded:
                    // called when a video ad has ended playing (but hasn't yet closed)
                    Debug.Log("Ad ended callback...");
                    break;
    
                case SAEvent.adClosed:
                    // called when a fullscreen ad is closed
                    Debug.Log("Ad closed callback...");
                    break;
            }
        }
    }
    
  6. Create some sort of UI that should call PlayInterstitial() method from above script
  7. Open buildxcode settings,and drag and drop the 4 files from SuperAwesomeiOS.zip into the Framework and iPhone tabs (check Exportcopy Projectfiles if needed checkbox)
  8. checkbox
  9. The files from SuperAwesomeiOS.zip should not be embeded into the Framework but should be embeded into the iPhone project
  10. Disable bitcode from xcode settings(project's root/setting file and clickfind Export
    your way to the “Build Settings” tab. Use the search bar to find “Bitcode” and change the setting to disabled)
  11. OpenMake the exported project in Android Studio and add missing mavenCentral() repository and kotlin class path to Gradle Scripts -> build.gradle (Project: Export):
    allprojects {
    buildscript {
    repositories {
    mavenCentral()
    google()
    jcenter()
    }

    dependencies {
    // Ifsure you are changingusing thecorrect Androidbundle Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
    // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
    // See official Gradleid and Androidteam Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
    // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
    classpath 'com.android.tools.build:gradle:4.0.1'
    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20'
    }
    }

    repositories {
    mavenCentral()
    google()
    jcenter()
    flatDir {
    dirs "${project(':unityLibrary').projectDir}/libs"
    }
    }
    }

    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    settings
  12. In the exported project in Android Studio add missing directive to Gradle Scripts -> build.gradle(Module: Export.launcher):
    apply plugin: 'kotlin-android'

  13. Click sync project with gradle files button (elephant looking icon on the top right side of the screen) and wait for Android Studio to download/import all the required packages.
  14. Go back to Unity, click Export again then Build or Build & Runrun andon adsa should be working when clicking the button.device/simulator

Note: StepsSuperAwesomeiOS.zip 6will -> 10 are currently done automatically by two post processor scripts created by us. If you delete the package in order to upgrade it you should add back those two scripts afterwards! In later versions these scripts mighteventually be included in the package,Unity inpackage whichso casestep you3 don'twill havenot tobe re-addrequired them.and steps 7-9 will be done automatically but are not done at the time of writing this guide.