21 private const string AdAlreadyPresentedErrorMessage =
22 "Rewarded ad was already presented. Single Rewarded ad can be presented just once.";
54 private IRewardedAdClient _client;
55 private bool _adShown;
59 this._client = client;
60 this._adShown =
false;
62 MainThreadDispatcher.initialize();
63 ConfigureRewardedAdEvents(this._client);
72 return this._client.GetInfo();
89 Message = AdAlreadyPresentedErrorMessage
114 this.OnAdShown =
null;
115 this.OnAdFailedToShow =
null;
116 this.OnAdImpression =
null;
117 this.OnAdClicked =
null;
118 this.OnAdDismissed =
null;
119 this.OnRewarded =
null;
122 private void ConfigureRewardedAdEvents(IRewardedAdClient client)
129 client.OnAdShown += (sender, args) =>
131 if (this.OnAdShown ==
null)
136 MainThreadDispatcher.EnqueueAction(() =>
138 if (this.OnAdShown ==
null)
147 client.OnAdFailedToShow += (sender, args) =>
149 if (this.OnAdFailedToShow ==
null)
154 MainThreadDispatcher.EnqueueAction(() =>
156 if (this.OnAdFailedToShow ==
null)
165 client.OnAdDismissed += (sender, args) =>
167 if (this.OnAdDismissed ==
null)
172 MainThreadDispatcher.EnqueueAction(() =>
174 if (this.OnAdDismissed ==
null)
183 client.OnAdImpression += (sender, args) =>
185 if (this.OnAdImpression ==
null)
190 MainThreadDispatcher.EnqueueAction(() =>
192 if (this.OnAdImpression ==
null)
201 client.OnAdClicked += (sender, args) =>
203 if (this.OnAdClicked ==
null)
208 MainThreadDispatcher.EnqueueAction(() =>
210 if (this.OnAdClicked ==
null)
219 client.OnRewarded += (sender, args) =>
221 if (this.OnRewarded ==
null)
226 MainThreadDispatcher.EnqueueAction(() =>
228 if (this.OnRewarded ==
null)