Esempio n. 1
0
        public void notifyNativeRequestResponse(String body)
        {
            TapsellPlusNativeBannerAd result = JsonUtility.FromJson <TapsellPlusNativeBannerAd> (body);

            Debug.Log("notifyNativeRequestResponse:" + result.zoneId);
            TapsellPlus.onNativeRequestResponse(result);
        }
        internal static IEnumerator loadNativeBannerAdImages(TapsellPlusNativeBannerAd result)
        {
            if (result.iconUrl != null && !result.iconUrl.Equals(""))
            {
                UnityWebRequest wwwIcon = UnityWebRequestTexture.GetTexture(result.iconUrl);
                yield return(wwwIcon.SendWebRequest());

                if (wwwIcon.isNetworkError || wwwIcon.isHttpError)
                {
                    Debug.Log(wwwIcon.error);
                }
                else
                {
                    result.iconImage = ((DownloadHandlerTexture)wwwIcon.downloadHandler).texture;
                }
            }

            if (result.portraitStaticImageUrl != null && !result.portraitStaticImageUrl.Equals(""))
            {
                UnityWebRequest wwwPortrait = UnityWebRequestTexture.GetTexture(result.portraitStaticImageUrl);
                yield return(wwwPortrait.SendWebRequest());

                if (wwwPortrait.isNetworkError || wwwPortrait.isHttpError)
                {
                    Debug.Log(wwwPortrait.error);
                }
                else
                {
                    result.portraitBannerImage = ((DownloadHandlerTexture)wwwPortrait.downloadHandler).texture;
                }
            }

            if (result.landscapeStaticImageUrl != null && !result.landscapeStaticImageUrl.Equals(""))
            {
                UnityWebRequest wwwLandscape = UnityWebRequestTexture.GetTexture(result.landscapeStaticImageUrl);
                yield return(wwwLandscape.SendWebRequest());

                if (wwwLandscape.isNetworkError || wwwLandscape.isHttpError)
                {
                    Debug.Log(wwwLandscape.error);
                }
                else
                {
                    result.landscapeBannerImage = ((DownloadHandlerTexture)wwwLandscape.downloadHandler).texture;
                }
            }

            CallIfAvailable(nativeBannerResponsePool, result.zoneId, result);
        }
 internal static void onNativeRequestResponse(TapsellPlusNativeBannerAd result)
 {
     if (result != null)
     {
         if (mMonoBehaviour != null && mMonoBehaviour.isActiveAndEnabled)
         {
             mMonoBehaviour.StartCoroutine(loadNativeBannerAdImages(result));
         }
         else
         {
             Debug.Log("Invalid MonoBehaviour Object");
             onRequestError(new TapsellError(result.zoneId, "Invalid MonoBehaviour Object"));
         }
     }
     else
     {
         Debug.Log("Invalid Native Banner Ad Result");
         onRequestError(new TapsellError(result.zoneId, "Invalid Native Banner Ad Result"));
     }
 }
Esempio n. 4
0
        private static void HandleOnUnifiedNativeAdLoaded(object sender, UnifiedNativeAdEventArgs args)
        {
            var       iconTexture          = args.nativeAd.GetIconTexture();
            Texture2D landscapeBannerImage = null;

            if (args.nativeAd.GetImageTextures().Count > 0)
            {
                var goList = args.nativeAd.GetImageTextures();
                landscapeBannerImage = goList[0];
            }

            SendAdMobNativeAdSuccessReport(_adMobNativeAdResponseId, _adMobNativeAdNetworkZoneId);
            var tapsellPlusNativeBannerAd =
                new TapsellPlusNativeBannerAd(_adMobNativeAdResponseId, _adMobNativeAdZoneId,
                                              "admob", args.nativeAd.GetHeadlineText(),
                                              args.nativeAd.GetBodyText(), args.nativeAd.GetCallToActionText(),
                                              null, landscapeBannerImage,
                                              iconTexture, args.nativeAd);

            _adMobNativeBannerAd = tapsellPlusNativeBannerAd;
            OnRequestResponse(new TapsellPlusAdModel(_adMobNativeAdResponseId, _adMobNativeAdZoneId));
        }
Esempio n. 5
0
        private static IEnumerator LoadTapsellNativeAdComponents(TapsellPlusNativeAd tapsellPlusNativeAd)
        {
            var       tapsellNativeAd      = tapsellPlusNativeAd.generalNativeAdModel;
            Texture2D iconImage            = null;
            Texture2D portraitBannerImage  = null;
            Texture2D landscapeBannerImage = null;

            if (tapsellNativeAd.iconUrl != null && !tapsellNativeAd.iconUrl.Equals(""))
            {
                var wwwIcon = UnityWebRequestTexture.GetTexture(tapsellNativeAd.iconUrl);
                yield return(wwwIcon.SendWebRequest());

                if (wwwIcon.result == UnityWebRequest.Result.ConnectionError ||
                    wwwIcon.result == UnityWebRequest.Result.ProtocolError)
                {
                    Debug.Log(wwwIcon.error);
                }
                else
                {
                    iconImage = ((DownloadHandlerTexture)wwwIcon.downloadHandler).texture;
                }
            }

            if (tapsellNativeAd.portraitStaticImageUrl != null && !tapsellNativeAd.portraitStaticImageUrl.Equals(""))
            {
                var wwwPortrait = UnityWebRequestTexture.GetTexture(tapsellNativeAd.portraitStaticImageUrl);
                yield return(wwwPortrait.SendWebRequest());

                if (wwwPortrait.result == UnityWebRequest.Result.ConnectionError ||
                    wwwPortrait.result == UnityWebRequest.Result.ProtocolError)
                {
                    Debug.Log(wwwPortrait.error);
                }
                else
                {
                    portraitBannerImage = ((DownloadHandlerTexture)wwwPortrait.downloadHandler).texture;
                }
            }

            if (tapsellNativeAd.landscapeStaticImageUrl != null && !tapsellNativeAd.landscapeStaticImageUrl.Equals(""))
            {
                var wwwLandscape = UnityWebRequestTexture.GetTexture(tapsellNativeAd.landscapeStaticImageUrl);
                yield return(wwwLandscape.SendWebRequest());

                if (wwwLandscape.result == UnityWebRequest.Result.ConnectionError ||
                    wwwLandscape.result == UnityWebRequest.Result.ProtocolError)
                {
                    Debug.Log(wwwLandscape.error);
                }
                else
                {
                    landscapeBannerImage = ((DownloadHandlerTexture)wwwLandscape.downloadHandler).texture;
                }
            }

            var tapsellPlusNativeBannerAd
                = new TapsellPlusNativeBannerAd(tapsellPlusNativeAd.responseId, tapsellPlusNativeAd.zoneId,
                                                "Tapsell", tapsellNativeAd.title,
                                                tapsellNativeAd.description, tapsellNativeAd.callToActionText,
                                                portraitBannerImage, landscapeBannerImage,
                                                iconImage, null);

            CallIfAvailable(OpenNativeAdCallbackPool, tapsellPlusNativeAd.responseId, tapsellPlusNativeBannerAd);
        }