Beispiel #1
0
 internal static void OnTapsellNativeAdOpened(TapsellPlusNativeAd tapsellPlusNativeAd)
 {
     if (tapsellPlusNativeAd.generalNativeAdModel != null)
     {
         if (_mMonoBehaviour != null && _mMonoBehaviour.isActiveAndEnabled)
         {
             if (tapsellPlusNativeAd.generalNativeAdModel.adNetwork.Equals("TAPSELL",
                                                                           StringComparison.InvariantCultureIgnoreCase))
             {
                 _mMonoBehaviour.StartCoroutine(LoadTapsellNativeAdComponents(tapsellPlusNativeAd));
             }
         }
         else
         {
             Debug.Log("Invalid MonoBehaviour Object");
             OnAdShowError(new TapsellPlusErrorModel(tapsellPlusNativeAd.responseId, tapsellPlusNativeAd.zoneId,
                                                     "Invalid MonoBehaviour Object"));
         }
     }
     else
     {
         Debug.Log("Invalid Native Banner Ad Result");
         OnAdShowError(new TapsellPlusErrorModel(tapsellPlusNativeAd.responseId, tapsellPlusNativeAd.zoneId,
                                                 "Invalid Native Banner Ad Result"));
     }
 }
Beispiel #2
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);
        }