//------------------------------------------------------------ // Init. //------------------------------------------------------------ public void Init(AdSettings settings) { #if EM_HEYZAP if (isInitialized) { Debug.Log("Heyzap client is already initialized. Ignoring this call."); return; } // Store a reference to the global settings. globalAdSettings = settings; // Start Heyzap with no automatic fetching since we'll handle ad loading. HeyzapAds.Start(globalAdSettings.HeyzapPublisherId, HeyzapAds.FLAG_DISABLE_AUTOMATIC_FETCHING); // Add callback handlers HZBannerAd.SetDisplayListener(BannerAdCallback); HZInterstitialAd.SetDisplayListener(InterstitialAdCallback); HZIncentivizedAd.SetDisplayListener(RewardedAdCallback); isInitialized = true; Debug.Log("Heyzap client has been initialized."); #else Debug.LogError(NO_SDK_MESSAGE); #endif }
protected override void InternalInit() { #if EM_HEYZAP // Store a reference to the global settings. mGlobalAdSettings = EM_Settings.Advertising.Heyzap; // Set GPDR consent (if any) *before* starting the SDK // https://developers.heyzap.com/docs/unity_sdk_setup_and_requirements var consent = GetApplicableDataPrivacyConsent(); ApplyDataPrivacyConsent(consent); // Start Heyzap with no automatic fetching since we'll handle ad loading. HeyzapAds.Start(mGlobalAdSettings.PublisherId, HeyzapAds.FLAG_DISABLE_AUTOMATIC_FETCHING); // Add callback handlers HZBannerAd.SetDisplayListener(BannerAdCallback); HZInterstitialAd.SetDisplayListener(InterstitialAdCallback); HZIncentivizedAd.SetDisplayListener(RewardedAdCallback); HeyzapAds.SetNetworkCallbackListener(NetworkCallbackListener); mIsInitialized = true; Debug.Log("Heyzap client has been initialized."); #else Debug.LogError(NO_SDK_MESSAGE); #endif }
// Use this for initialization void Start() { StoreEvents.OnMarketPurchase += onMarketPurchase; StoreEvents.OnUnexpectedStoreError += onUnexpectedStoreError; HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag){ if (adState.Equals("incentivized_result_complete")) { // The user has watched the entire video and should be given a reward. GameData.Instance.multiRemainingGameCount += 5; GameData.Instance.rewardedGameCount += 5; GameData.Instance.Save(); } if (adState.Equals("incentivized_result_incomplete")) { // The user did not watch the entire video and should not be given a reward. } }; HZIncentivizedAd.SetDisplayListener(listener); HZIncentivizedAd.Fetch(); // if (GameData.Instance.multiRemainingGameCount <= 0) { // active = true; //// checkDailyLimitExceed (); // } else { // active = false; // } // if (StoreInventory.GetItemBalance (NumberGameAssets.NO_ADS_ITEM_ID) > 0) { // noAds.enabled = false; // noAds.GetComponentInChildren<Text>().text = "All ads removed"; // } }
// Use this for initialization void Start() { selectedColor = new Color(1, 205.0f / 255, 106.0f / 255, 1); unselectColor = new Color(1, 1, 1, 0); themeBtnBg.GetComponent <Outline>().effectColor = selectedColor; achvBtnBg.GetComponent <Outline>().effectColor = unselectColor; diamongBtnBg.GetComponent <Outline>().effectColor = unselectColor; themesTab.gameObject.SetActive(true); achivementTab.gameObject.SetActive(false); diamondTab.gameObject.SetActive(false); settingPanel.gameObject.SetActive(false); rewardPanel.gameObject.SetActive(false); if (GameData.gameType == EGameType.ThemeSelection) { mainCatPanel.gameObject.SetActive(false); subCatPanel.gameObject.SetActive(true); } else { if (!mainCatPanel.gameObject.activeSelf) { mainCatPanel.gameObject.SetActive(true); subCatPanel.gameObject.SetActive(false); } } HZIncentivizedAd.SetDisplayListener(videoAdListener); HZIncentivizedAd.Fetch(); }
protected override void RemoveEventListeners() { #if API_ADS_HEYZAP HZBannerAd.SetDisplayListener(null); HZInterstitialAd.SetDisplayListener(null); HZVideoAd.SetDisplayListener(null); HZIncentivizedAd.SetDisplayListener(null); #endif }
protected override void CreateEventListeners() { #if API_ADS_HEYZAP HZBannerAd.SetDisplayListener(OnBannerStateUpdate); HZInterstitialAd.SetDisplayListener(OnInterstitialStateUpdate); HZVideoAd.SetDisplayListener(OnInterstitialStateUpdate); HZIncentivizedAd.SetDisplayListener(OnIncentivizedStateUpdate); #endif }
// Use this for initialization void Start() { IsRewardedVideoReady = false; VideoAdCointer = 0; HeyzapAds.Start("70d6db5109295d28b9ab83165d3fa95c", HeyzapAds.FLAG_NO_OPTIONS); // HeyzapAds.ShowMediationTestSuite(); // Interstitial ads are automatically fetched HZInterstitialAd.Fetch("app-launch"); HZVideoAd.Fetch("video"); HZIncentivizedAd.Fetch("rewarded"); HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag){ if (adState.Equals("incentivized_result_complete")) { // The user has watched the entire video and should be given a reward. GameEvents.Send(GiveReward); } if (adState.Equals("incentivized_result_incomplete")) { // The user did not watch the entire video and should not be given a reward. } if (adState.Equals("hide")) { // Sent when an ad has been removed from view. // This is a good place to unpause your app, if applicable. Defs.MuteSounds(false); } if (adState.Equals("available")) { IsRewardedVideoReady = true; // Sent when an ad has been loaded and is ready to be displayed, // either because we autofetched an ad or because you called // `Fetch`. } }; HZIncentivizedAd.SetDisplayListener(listener); HZVideoAd.AdDisplayListener listenerVideo = delegate(string adState, string adTag){ if (adState.Equals("hide")) { // Sent when an ad has been removed from view. // This is a good place to unpause your app, if applicable. Defs.MuteSounds(false); } }; HZVideoAd.SetDisplayListener(listenerVideo); }
void SetRewardAdListener() { HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag) { if (adState.Equals("show")) { //Ad showing, pause game } if (adState.Equals("hide")) { //Ad gone, unpause game } if (adState.Equals("click")) { } if (adState.Equals("failed")) { } if (adState.Equals("available")) { } if (adState.Equals("fetch_failed")) { } if (adState.Equals("audio_starting")) { //mute game sound } if (adState.Equals("audio_finished")) { //unmute game sound } if (adState.Equals("incentivized_result_complete")) { //reward player here OnRewardAdCompleted(adTag); Toaster.ShowDebugToast("Reward ad Conpleted for tag; " + adTag); } if (adState.Equals("incentivized_result_incomplete")) { OnRewardAdSkipped(adTag); Toaster.ShowDebugToast("Reward ad 'Skipped' for tag; " + adTag); } }; HZIncentivizedAd.SetDisplayListener(listener); }
void Start() { HeyzapAds.Start("3a045a04722e168baefdd3eeff198305", HeyzapAds.FLAG_NO_OPTIONS); HZVideoAd.Fetch(); HZIncentivizedAd.Fetch(); HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag) { if (adState.Equals("incentivized_result_complete")) { PlayerPrefs.SetInt("currentShards", PlayerPrefs.GetInt("currentShards") + 10); } if (adState.Equals("incentivized_result_incomplete")) { //Don give him/her shards } }; HZIncentivizedAd.SetDisplayListener(listener); }
// Use this for initialization void Start() { canRestored = false; // array of product ID's from iTunesConnect. MUST match exactly what you have there! #if UNITY_IOS StoreKitManager.autoConfirmTransactions = true; var productIdentifiers = new string[] { Constants.PRODUCT_ID }; StoreKitBinding.requestProductData(productIdentifiers); #elif UNITY_ANDROID var skus = new string[] { Constants.PRODUCT_ID }; // var skus = new string[] { "com.prime31.testproduct", "android.test.purchased", "com.prime31.managedproduct", "com.prime31.testsubscription" }; GoogleIAB.queryInventory(skus); #endif HZIncentivizedAd.SetDisplayListener(videoAdListener); GameInit(); }
void Start() { HeyzapAds.NetworkCallbackListener networkCallbackListner = delegate(string network, string callback) { this.console.Append("[" + network + "]: " + callback); }; HeyzapAds.SetNetworkCallbackListener(networkCallbackListner); HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS); HZBannerAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("BANNER: " + adState + " Tag : " + adTag); if (adState == "loaded") { Rect dimensions = new Rect(); HZBannerAd.GetCurrentBannerDimensions(out dimensions); this.console.Append(string.Format(" (x,y): ({0},{1}) - WxH: {2}x{3}", dimensions.x, dimensions.y, dimensions.width, dimensions.height)); } }); HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("INTERSTITIAL: " + adState + " Tag : " + adTag); }); HZIncentivizedAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("INCENTIVIZED: " + adState + " Tag : " + adTag); }); HZVideoAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("VIDEO: " + adState + " Tag : " + adTag); }); this.bannerControls.SetActive(false); this.nonBannerControls.SetActive(true); // UI defaults this.bannerPosition = HZBannerShowOptions.POSITION_TOP; this.SelectedAdType = AdType.Interstitial; HeyzapAds.HideDebugLogs(); }
private void ShowIncentiveAds() { HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag) { if (adState.Equals("fetch_failed")) { //TELL USER TO CHECK CONNECTION HZIncentivizedAd.Fetch(); } if (adState.Equals("incentivized_result_complete")) { // Give reward to the player RewardToPlayer(); HZIncentivizedAd.Fetch(); } if (adState.Equals("incentivized_result_incomplete")) { // The user did not watch the entire video and should not be given a reward. HZIncentivizedAd.Fetch(); } }; HZIncentivizedAd.SetDisplayListener(listener); }
void Start() { HeyzapAds.NetworkCallbackListener networkCallbackListener = delegate(string network, string callback) { this.console.Append("[" + network + "]: " + callback); }; // HZDemographics.SetUserGender(HZDemographics.Gender.MALE); // HZDemographics.SetUserPostalCode("94103"); // HZDemographics.SetUserHouseholdIncome(100000); // HZDemographics.SetUserMaritalStatus(HZDemographics.MaritalStatus.SINGLE); // HZDemographics.SetUserEducationLevel(HZDemographics.EducationLevel.BACHELORS_DEGREE); // HZDemographics.SetUserBirthDate("1990-08-05"); // UnityEngine.Debug.Log ("calling loc service"); // TestLocationService locServ = new TestLocationService(); // locServ.Start(this.console); HeyzapAds.SetNetworkCallbackListener(networkCallbackListener); HeyzapAds.ShowDebugLogs(); HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS); HZBannerAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("BANNER: " + adState + " Tag : " + adTag); if (adState == "loaded") { Rect dimensions = new Rect(); HZBannerAd.GetCurrentBannerDimensions(out dimensions); this.console.Append(string.Format(" (x,y): ({0},{1}) - WxH: {2}x{3}", dimensions.x, dimensions.y, dimensions.width, dimensions.height)); } }); HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("INTERSTITIAL: " + adState + " Tag : " + adTag); }); HZIncentivizedAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("INCENTIVIZED: " + adState + " Tag : " + adTag); }); HZVideoAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("VIDEO: " + adState + " Tag : " + adTag); }); HZOfferWallAd.SetDisplayListener(delegate(string adState, string adTag) { this.console.Append("OFFERWALL: " + adState + " Tag : " + adTag); }); HZOfferWallAd.SetVirtualCurrencyResponseListener(delegate(VirtualCurrencyResponse response) { this.console.Append("OFFERWALL VCS Response: id:" + response.CurrencyID + " name: '" + response.CurrencyName + "' amount : " + response.DeltaOfCurrency + " trans: " + response.LatestTransactionID); }); HZOfferWallAd.SetVirtualCurrencyErrorListener(delegate(string errorMsg) { this.console.Append("OFFERWALL VCS Error: " + errorMsg); }); // UI defaults this.bannerPosition = HZBannerShowOptions.POSITION_TOP; this.SelectedAdType = AdType.Interstitial; this.ShowAdTypeControls(); }
/// <summary> /// Ads all Heyzap SDK listeners /// </summary> private void AdListeners() { if (debug) { Debug.Log(this + " add listeners"); ScreenWriter.Write(this + " add listeners"); } HZInterstitialAd.AdDisplayListener listener = delegate(string adState, string adTag) { if (adState.Equals("show")) { if (debug) { Debug.Log(this + " show event triggered"); ScreenWriter.Write(this + " show event triggered interstitial"); } } if (adState.Equals("hide")) { if (debug) { Debug.Log(this + " hide event triggered"); ScreenWriter.Write(this + " hide event triggered interstitial"); } if (OnInterstitialClosed != null) { OnInterstitialClosed(); OnInterstitialClosed = null; } if (OnInterstitialClosedWithAdvertiser != null) { OnInterstitialClosedWithAdvertiser(SupportedAdvertisers.Heyzap.ToString()); OnInterstitialClosedWithAdvertiser = null; } HZInterstitialAd.Fetch(); } if (adState.Equals("failed")) { if (debug) { Debug.Log(this + " failed event triggered"); ScreenWriter.Write(this + " failed event triggered interstitial"); } } if (adState.Equals("available")) { if (debug) { Debug.Log(this + " available event triggered"); ScreenWriter.Write(this + " available event triggered interstitial"); } } if (adState.Equals("fetch_failed")) { if (debug) { Debug.Log(this + " fetch_failed event triggered"); ScreenWriter.Write(this + " fetch_failed event triggered interstitial"); } } }; HZIncentivizedAd.AdDisplayListener listenerRewarded = delegate(string adState, string adTag) { if (adState.Equals("show")) { if (debug) { Debug.Log(this + " show event triggered rewarded"); ScreenWriter.Write(this + " show event triggered rewarded"); } } if (adState.Equals("hide")) { if (debug) { Debug.Log(this + " hide event triggered rewarded"); ScreenWriter.Write(this + " hide event triggered rewarded"); } HZIncentivizedAd.Fetch(); } if (adState.Equals("failed")) { if (debug) { Debug.Log(this + " failed event triggered rewarded"); ScreenWriter.Write(this + " failed event triggered rewarded"); } } if (adState.Equals("available")) { if (debug) { Debug.Log(this + " available event triggered rewarded"); ScreenWriter.Write(this + " available event triggered rewarded"); } } if (adState.Equals("fetch_failed")) { if (debug) { Debug.Log(this + " fetch_failed event triggered rewarded"); ScreenWriter.Write(this + " fetch_failed event triggered rewarded"); } } if (adState.Equals("incentivized_result_complete")) { if (OnCompleteMethod != null) { OnCompleteMethod(true); OnCompleteMethod = null; } if (OnCompleteMethodWithAdvertiser != null) { OnCompleteMethodWithAdvertiser(true, SupportedAdvertisers.Heyzap.ToString()); OnCompleteMethodWithAdvertiser = null; } } if (adState.Equals("incentivized_result_incomplete")) { if (OnCompleteMethod != null) { OnCompleteMethod(false); OnCompleteMethod = null; } if (OnCompleteMethodWithAdvertiser != null) { OnCompleteMethodWithAdvertiser(false, SupportedAdvertisers.Heyzap.ToString()); OnCompleteMethodWithAdvertiser = null; } } }; HZBannerAd.AdDisplayListener listenerBanner = delegate(string adState, string adTag) { if (debug) { Debug.Log(this + " " + adState + " " + adTag); ScreenWriter.Write(this + " " + adState + " " + adTag); } if (adState == "loaded") { if (debug) { Debug.Log(this + " loaded event triggered banner"); ScreenWriter.Write(this + " loaded event triggered banner"); } if (DisplayResult != null) { DisplayResult(true, position, bannerType); DisplayResult = null; } } if (adState == "error") { if (debug) { Debug.Log(this + " error event triggered banner"); ScreenWriter.Write(this + " error event triggered banner"); } if (DisplayResult != null) { DisplayResult(false, position, bannerType); DisplayResult = null; } } if (adState == "click") { if (debug) { Debug.Log(this + " click event triggered banner"); ScreenWriter.Write(this + " click event triggered banner"); } } }; HZInterstitialAd.SetDisplayListener(listener); HZIncentivizedAd.SetDisplayListener(listenerRewarded); HZBannerAd.SetDisplayListener(listenerBanner); }
// Update is called once per frame void Update() { //You can set a listener on HZInterstitialAd, HZVideoAd, HZIncentivizedAd, and HZOfferWallAd. HZIncentivizedAd.AdDisplayListener listenerReward = delegate(string adState, string adTag) { if (adState.Equals("incentivized_result_complete")) { // The user has watched the entire video and should be given a reward. } if (adState.Equals("incentivized_result_incomplete")) { // The user did not watch the entire video and should not be given a reward. } }; HZIncentivizedAd.SetDisplayListener(listenerReward); HZInterstitialAd.AdDisplayListener listenerInterstitial = delegate(string adState, string adTag) { if (adState.Equals("show")) { // Sent when an ad has been displayed. // This is a good place to pause your app, if applicable. } if (adState.Equals("hide")) { // Sent when an ad has been removed from view. // This is a good place to unpause your app, if applicable. } if (adState.Equals("click")) { // Sent when an ad has been clicked by the user. } if (adState.Equals("failed")) { // Sent when you call `show`, but there isn't an ad to be shown. // Some of the possible reasons for show errors: // - `HeyzapAds.PauseExpensiveWork()` was called, which pauses // expensive operations like SDK initializations and ad // fetches, andand `HeyzapAds.ResumeExpensiveWork()` has not // yet been called // - The given ad tag is disabled (see your app's Publisher // Settings dashboard) // - An ad is already showing // - A recent IAP is blocking ads from being shown (see your // app's Publisher Settings dashboard) // - One or more of the segments the user falls into are // preventing an ad from being shown (see your Segmentation // Settings dashboard) // - Incentivized ad rate limiting (see your app's Publisher // Settings dashboard) // - One of the mediated SDKs reported it had an ad to show // but did not display one when asked (a rare case) // - The SDK is waiting for a network request to return before an // ad can show } if (adState.Equals("available")) { // Sent when an ad has been loaded and is ready to be displayed, // either because we autofetched an ad or because you called // `Fetch`. } if (adState.Equals("fetch_failed")) { // Sent when an ad has failed to load. // This is sent with when we try to autofetch an ad and fail, and also // as a response to calls you make to `Fetch` that fail. // Some of the possible reasons for fetch failures: // - Incentivized ad rate limiting (see your app's Publisher // Settings dashboard) // - None of the available ad networks had any fill // - Network connectivity // - The given ad tag is disabled (see your app's Publisher // Settings dashboard) // - One or more of the segments the user falls into are // preventing an ad from being fetched (see your // Segmentation Settings dashboard) } if (adState.Equals("audio_starting")) { // The ad about to be shown will need audio. // Mute any background music. } if (adState.Equals("audio_finished")) { // The ad being shown no longer needs audio. // Any background music can be resumed. } }; HZInterstitialAd.SetDisplayListener(listenerInterstitial); if (GameController.adCount == 3) { if (!HZVideoAd.IsAvailable()) { FetchVideoAd(); } } if (GameController.adCount >= 5) { GameController.adCount = 0; int rand = Random.Range(0, 2); if (rand == 0) { ShowInterstitialAd(); } else { ShowVideoAd(); } } }
public override void SetCallbacks() { #region banner_callback HZBannerAd.AdDisplayListener listener = delegate(string adState, string adTag) { if (adState == "click") { ClickAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "Banner_click", ""); } if (adState == "loaded") { // Do something when the banner ad is loaded } if (adState == "error") { // Do something when the banner ad fails to load (they can fail when refreshing after successfully loading) } }; HZBannerAd.SetDisplayListener(listener); #endregion #region interstitial_callback HZInterstitialAd.AdDisplayListener listenerInterstitial = delegate(string adState, string adTag) { if (adState.Equals("show")) { ShowAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "show", adTag); } if (adState.Equals("hide")) { Analytic.Instance.CustomEvent("ADS", "hide", adTag); } if (adState.Equals("click")) { ClickAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "click", adTag); } if (adState.Equals("failed")) { Analytic.Instance.CustomEvent("ADS", "failed", adTag); } if (adState.Equals("available")) { AvailableAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "available", adTag); } if (adState.Equals("fetch_failed")) { Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag); } if (adState.Equals("audio_starting")) { Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag); } if (adState.Equals("audio_finished")) { Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag); } }; HZInterstitialAd.SetDisplayListener(listenerInterstitial); #endregion #region video_callback HZVideoAd.AdDisplayListener listenerVideo = delegate(string adState, string adTag) { if (adState.Equals("show")) { ShowAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "show", adTag); } if (adState.Equals("hide")) { Analytic.Instance.CustomEvent("ADS", "hide", adTag); } if (adState.Equals("click")) { ClickAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "click", adTag); } if (adState.Equals("failed")) { Analytic.Instance.CustomEvent("ADS", "failed", adTag); } if (adState.Equals("available")) { AvailableAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "available", adTag); } if (adState.Equals("fetch_failed")) { Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag); } if (adState.Equals("audio_starting")) { Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag); } if (adState.Equals("audio_finished")) { Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag); } }; HZVideoAd.SetDisplayListener(listenerVideo); #endregion #region rewarded_callback HZIncentivizedAd.AdDisplayListener listenerRewarded = delegate(string adState, string adTag) { if (adState.Equals("show")) { Analytic.Instance.CustomEvent("ADS", "show", adTag); } if (adState.Equals("hide")) { Analytic.Instance.CustomEvent("ADS", "hide", adTag); } if (adState.Equals("click")) { ClickAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "click", adTag); } if (adState.Equals("failed")) { Analytic.Instance.CustomEvent("ADS", "failed", adTag); } if (adState.Equals("available")) { AvailableAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "available", adTag); } if (adState.Equals("fetch_failed")) { Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag); } if (adState.Equals("audio_starting")) { Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag); } if (adState.Equals("audio_finished")) { Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag); } if (adState.Equals("incentivized_result_complete")) { ShowAdsEvent(adTag); Analytic.Instance.CustomEvent("ADS", "incentivized_result_complete", adTag); } if (adState.Equals("incentivized_result_incomplete")) { Analytic.Instance.CustomEvent("ADS", "incentivized_result_incomplete", adTag); } }; HZIncentivizedAd.SetDisplayListener(listenerRewarded); #endregion }