Пример #1
0
        private void FireRequestCallback(NativeMessage message, AdFormat format)
        {
            RequestCallback callback = GetCallback <RequestCallback>(message.Id);

            if (message.RequestPayload.AdAvailable.GetValueOrDefault())
            {
                Ad ad = new Ad(message.Id);
                ad.AdFormat = format;

                if (!string.IsNullOrEmpty(message.RequestPayload.PlacementId))
                {
                    ad.PlacementId = message.RequestPayload.PlacementId;
                }

                callback.OnAdAvailable(ad as Ad);
            }
            else
            {
                callback.OnAdNotAvailable(format);
            }
        }
Пример #2
0
        private void FireAdCallback(NativeMessage message, AdFormat adFormat)
        {
            var        adPayload = message.AdPayload;
            AdCallback callback  = GetCallback <AdCallback>(message.Id, !adPayload.AdStarted);

            if (adPayload.AdStarted)
            {
                if (ads.ContainsKey(message.Id))
                {
                    Ad ad = ads[message.Id];
                    // only remove if it's not a banner
                    ads.Remove(message.Id);
                    callback.OnAdStarted(ad);
                }
                else
                {
                    ClearCallbacks(message.Id);
                    FyberCallback.Instance.OnNativeError("An unknown error occurred. Please, request Ads again.");
                }
            }
            else
            {
                AdResult result = new AdResult();
                if (string.IsNullOrEmpty(adPayload.Error))
                {
                    result.Status  = AdStatus.OK;
                    result.Message = adPayload.Status;
                }
                else
                {
                    result.Status  = AdStatus.Error;
                    result.Message = adPayload.Error;
                }
                result.AdFormat = adFormat;
                callback.OnAdFinished(result);
            }
        }
Пример #3
0
 internal static void AddAd(string guid, Ad ad)
 {
     Instance.ads[guid] = ad;
 }