Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by registered user gOzaru84 ( 7 years ago )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AppodealAds.Unity.Api;
using AppodealAds.Unity.Common;
public class AdsManager : MonoBehaviour, IPermissionGrantedListener, IInterstitialAdListener, INonSkippableVideoAdListener
{
#if UNITY_EDITOR && !UNITY_ANDROID && !UNITY_IPHONE
string appKey = "";
#elif UNITY_ANDROID
string appKey = "9ec4fa9d8e905a915f8433ddeb6ff3d46e83d64c6c61fbc7";
#elif UNITY_IPHONE
string appKey = "4b46ef930cd37cf11da84ae4d41019abb7234d5bbce3f000";
#else
string appKey = "";
#endif
public static AdsManager Instance { get; private set; }
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
else
{
if (Instance != this)
{
Destroy(gameObject);
}
}
Appodeal.requestAndroidMPermissions(this);
}
public void Init()
{
Appodeal.setTesting(true);
Appodeal.disableLocationPermissionCheck();
Appodeal.disableWriteExternalStoragePermissionCheck();
Appodeal.muteVideosIfCallsMuted(true);
Appodeal.setExtraData(ExtraData.APPSFLYER_ID, "1527256526604-2129416");
int gdpr = PlayerPrefs.GetInt("result_gdpr_sdk", 0);
Appodeal.disableNetwork("inmobi");
Appodeal.disableNetwork("mmedia");
Appodeal.disableNetwork("ogury");
Appodeal.setAutoCache(Appodeal.INTERSTITIAL, true);
Appodeal.setAutoCache(Appodeal.NON_SKIPPABLE_VIDEO, true);
Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.NON_SKIPPABLE_VIDEO, gdpr == 1);
Appodeal.setInterstitialCallbacks(this);
Appodeal.setNonSkippableVideoCallbacks(this);
}
public void showInterstitial()
{
if (Appodeal.isLoaded(Appodeal.INTERSTITIAL) && !Appodeal.isPrecache(Appodeal.INTERSTITIAL))
{
Appodeal.show(Appodeal.INTERSTITIAL);
}
}
public void showNonSkippableVideo()
{
if (Appodeal.isLoaded(Appodeal.NON_SKIPPABLE_VIDEO))
{
Appodeal.show(Appodeal.NON_SKIPPABLE_VIDEO);
}
}
#region Interstitial callback handlers
public void onInterstitialLoaded(bool isPrecache)
{
print("Appodeal. Interstitial loaded");
}
public void onInterstitialFailedToLoad() { print("Appodeal. Interstitial failed"); }
public void onInterstitialShown()
{
print("Appodeal. Interstitial opened");
}
public void onInterstitialClosed() { print("Appodeal. Interstitial closed"); }
public void onInterstitialClicked() { print("Appodeal. Interstitial clicked"); }
public void onInterstitialExpired() { print("Appodeal. Interstitial expired"); }
#endregion
#region Non Skippable Video callback handlers
public void onNonSkippableVideoLoaded(bool isPrecache) { Debug.Log("NonSkippable Video loaded"); }
public void onNonSkippableVideoFailedToLoad() { Debug.Log("NonSkippable Video failed to load"); }
public void onNonSkippableVideoShown() { Debug.Log("NonSkippable Video opened"); }
public void onNonSkippableVideoClosed(bool isFinished) { Debug.Log("NonSkippable Video, finished:" + isFinished); }
public void onNonSkippableVideoFinished() { Debug.Log("NonSkippable Video finished"); }
public void onNonSkippableVideoExpired() { Debug.Log("NonSkippable Video expired"); }
#endregion
public void writeExternalStorageResponse(int result)
{
if (result == 0)
{
Debug.Log("WRITE_EXTERNAL_STORAGE permission granted");
}
else
{
Debug.Log("WRITE_EXTERNAL_STORAGE permission grant refused");
}
}
public void accessCoarseLocationResponse(int result)
{
if (result == 0)
{
Debug.Log("ACCESS_COARSE_LOCATION permission granted");
}
else
{
Debug.Log("ACCESS_COARSE_LOCATION permission grant refused");
}
}
}
Revise this Paste