// Caches an interstitial. Location is used for tracking in the Chartboost web portal. public static void cacheInterstitial(string location = "None") { #if UNITY_IPHONE ChartboostBinding.cacheInterstitial(location); #elif UNITY_ANDROID ChartboostAndroid.cacheInterstitial(location); #endif }
// Shows a rewarded video public static void showRewardedVideo(string location = "None") { #if UNITY_IPHONE ChartboostBinding.showRewardedVideo(location); #elif UNITY_ANDROID ChartboostAndroid.showRewardedVideo(location); #endif }
// Starts up Chartboost and records an app install public static void init(string androidAppId, string androidAppSignature, string iosAppId, string iosAppSignature, bool shouldRequestInterstitialsInFirstSession = true) { #if UNITY_IPHONE ChartboostBinding.init(iosAppId, iosAppSignature, shouldRequestInterstitialsInFirstSession); #elif UNITY_ANDROID ChartboostAndroid.init(androidAppId, androidAppSignature, shouldRequestInterstitialsInFirstSession); #endif }
// Shows the more apps screen public static void showMoreApps(string location = "None") { #if UNITY_IPHONE ChartboostBinding.showMoreApps(location); #elif UNITY_ANDROID ChartboostAndroid.showMoreApps(location); #endif }
// Checks to see if a rewarded video is cached for the given location public static bool hasCachedRewardedVideo(string location = "None") { #if UNITY_IPHONE return(ChartboostBinding.hasCachedRewardedVideo(location)); #elif UNITY_ANDROID return(ChartboostAndroid.hasCachedRewardedVideo(location)); #endif }
// Caches the more apps screen public static void cacheMoreApps() { #if UNITY_IPHONE ChartboostBinding.cacheMoreApps(); #elif UNITY_ANDROID ChartboostAndroid.cacheMoreApps(); #endif }
// Loads an interstitial. Location is optional. Pass in null if you do not want to specify the location. public static void showInterstitial(string location) { #if UNITY_IPHONE ChartboostBinding.showInterstitial(location); #elif UNITY_ANDROID ChartboostAndroid.showInterstitial(location); #endif }
// Checks to see if an interstitial is cached for the given location public static bool hasCachedInterstitial(string location = "None") { #if UNITY_IPHONE return(ChartboostBinding.hasCachedInterstitial(location)); #elif UNITY_ANDROID return(ChartboostAndroid.hasCachedInterstitial(location)); #else return(false); #endif }
// Tracks an event with optional meta data public static void trackEvent(string eventIdentifier, double value, Dictionary <string, object> metaData) { metaData = metaData ?? new Dictionary <string, object>(); #if UNITY_IPHONE ChartboostBinding.trackEventWithValueAndMetadata(eventIdentifier, (float)value, metaData); #elif UNITY_ANDROID ChartboostAndroid.trackEvent(eventIdentifier, value, metaData); #endif }
void OnGUI() { beginColumn(); if (GUILayout.Button("Init")) { ChartboostAndroid.init("YOUR_APP_ID", "YOUR_APP_SIGNATURE"); } if (GUILayout.Button("Cache Interstitial")) { ChartboostAndroid.cacheInterstitial(null); } if (GUILayout.Button("Check for Cached Interstitial")) { Debug.Log("has cached interstitial: " + ChartboostAndroid.hasCachedInterstitial(null)); } if (GUILayout.Button("Show Interstitial")) { ChartboostAndroid.showInterstitial(null); } if (GUILayout.Button("Cache More Apps")) { ChartboostAndroid.cacheMoreApps(); } if (GUILayout.Button("Has Cached More Apps")) { Debug.Log("has cached more apps: " + ChartboostAndroid.hasCachedMoreApps()); } if (GUILayout.Button("Show More Apps")) { ChartboostAndroid.showMoreApps(); } if (GUILayout.Button("Track Event")) { ChartboostAndroid.trackEvent("event-did-something", 0, null); } endColumn(); }
void Start() { Chartboost.init("55bb8a96c909a66315763faa", "5ee308bc8a482c70f6408d8a75a5789cad00d580", "55bb8a96c909a66315763fa9", "c70bb9fe554de9639e875dc6ccf2da3618a2517b"); ChartboostAndroid.setImpressionsUseActivities(true); Chartboost.cacheInterstitial(); Chartboost.cacheRewardedVideo(); }
void OnGUI() { beginColumn(); if (GUILayout.Button("Init")) { // Replace with your app ID and app signature!!! ChartboostAndroid.init("4f7b433509b6025804000002", "dd2d41b69ac01b80f443f5b6cf06096d457f82bd"); } if (GUILayout.Button("Use Activities for Adverts")) { ChartboostAndroid.setImpressionsUseActivities(true); } if (GUILayout.Button("Cache Interstitial")) { ChartboostAndroid.cacheInterstitial("ItemStore"); } if (GUILayout.Button("Is Interstitial Cached?")) { Debug.Log("is cached: " + ChartboostAndroid.hasCachedInterstitial("ItemStore")); } if (GUILayout.Button("Show Interstitial")) { ChartboostAndroid.showInterstitial("ItemStore"); } if (GUILayout.Button("Cache More Apps")) { ChartboostAndroid.cacheMoreApps("Startup"); } if (GUILayout.Button("Has Cached More Apps")) { Debug.Log("has cached more apps: " + ChartboostAndroid.hasCachedMoreApps("Startup")); } if (GUILayout.Button("Show More Apps")) { ChartboostAndroid.showMoreApps("Startup"); } endColumn(true); if (GUILayout.Button("Cache Rewarded Video")) { ChartboostAndroid.cacheRewardedVideo("VideoSpot"); } if (GUILayout.Button("Has Cached Rewarded Video")) { Debug.Log("has cached rewarded video: " + ChartboostAndroid.hasCachedRewardedVideo("VideoSpot")); } if (GUILayout.Button("Show Rewarded Video")) { ChartboostAndroid.showRewardedVideo("VideoSpot"); } endColumn(); }