21 private const string AdAlreadyPresentedErrorMessage =
22 "App open ad was already presented. Single App open ad can be presented just once.";
49 private IAppOpenAdClient _client;
50 private bool _adShown;
52 internal AppOpenAd(IAppOpenAdClient client)
54 this._client = client;
55 this._adShown =
false;
57 MainThreadDispatcher.initialize();
58 ConfigureAppOpenAdEvents(this._client);
75 Message = AdAlreadyPresentedErrorMessage
99 this.OnAdShown =
null;
100 this.OnAdFailedToShow =
null;
101 this.OnAdImpression =
null;
102 this.OnAdClicked =
null;
103 this.OnAdDismissed =
null;
106 private void ConfigureAppOpenAdEvents(IAppOpenAdClient client)
113 client.OnAdClicked += (sender, args) =>
115 if (this.OnAdClicked ==
null)
120 MainThreadDispatcher.EnqueueAction(() =>
122 if (this.OnAdClicked ==
null)
131 client.OnAdShown += (sender, args) =>
133 if (this.OnAdShown ==
null)
138 MainThreadDispatcher.EnqueueAction(() =>
140 if (this.OnAdShown ==
null)
149 client.OnAdDismissed += (sender, args) =>
151 if (this.OnAdDismissed ==
null)
156 MainThreadDispatcher.EnqueueAction(() =>
158 if (this.OnAdDismissed ==
null)
167 client.OnAdImpression += (sender, args) =>
169 if (this.OnAdImpression ==
null)
174 MainThreadDispatcher.EnqueueAction(() =>
176 if (this.OnAdImpression ==
null)
185 client.OnAdFailedToShow += (sender, args) =>
187 if (this.OnAdFailedToShow ==
null)
192 MainThreadDispatcher.EnqueueAction(() =>
194 if (this.OnAdFailedToShow ==
null)