-
Notifications
You must be signed in to change notification settings - Fork 22
/
cocoon_ads.js
745 lines (678 loc) · 26.1 KB
/
cocoon_ads.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
(function () {
if (!window.Cocoon && window.cordova && typeof require !== 'undefined') {
cordova.require('cocoon-plugin-common.Cocoon');
}
var Cocoon = window.Cocoon;
/**
* @fileOverview
<h2>About Atomic Plugins</h2>
<p>Atomic Plugins provide an elegant and minimalist API and are designed with portability in mind from the beginning. Framework dependencies are avoided by design so the plugins can run on any platform and can be integrated with any app framework or game engine.
<br/><p>You can contribute and help to create more awesome plugins. </p>
<h2>Atomic Plugins for Ads</h2>
<p>This repo contains Ad APIs designed using the Atomic Plugins paradigm. Monetize your app and take advantage of all the features provided: elegant API, flexible monetization solution that works across multiple platforms, full support for banners and full screen ads (interstitials), single API for different Ad Providers, etc. The API is already available in many languagues and we have the plan to add more in the future.</p>
<p>Currently there are 2 Ad providers implemented but new ones can be easily added:</p>
<ul>
<li>MoPub with optional adapters</li>
<li>AdMob</li>
</ul>
<h3>Setup your project</h3>
<p>Releases are deployed to NPM.
You only have to install the desired plugins using Cordova CLI and <a href="https://cocoon.io"/>Cocoon Cloud service</a>.</p>
<ul>
// MoPub<br/>
<code>cordova plugin add cocoon-plugin-ads-ios-admob</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-mopub</code><br/><br/>
// Optional MoPub adapters for iOS and Android<br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-adcolony</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-admob</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-chartboost</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-greystripe</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-inmobi</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub-millennialmedia</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-mopub-admob</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-mopub-chartboost</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-mopub-millennial</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-mopub-adcolony</code><br/><br/>
// AdMob<br/>
<code>cordova plugin add cocoon-plugin-ads-android-admob</code><br/>
<code>cordova plugin add cocoon-plugin-ads-android-mopub</code><br/><br/>
// Optional AdMob adapters for iOS and Android<br/>
<code>cordova plugin add cocoon-plugin-ads-android-admob-adcolony</code><br/>
<code>cordova plugin add cocoon-plugin-ads-ios-admob-adcolony</code><br/>
</ul>
<h3>Documentation</h3>
<p>In this section you will find all the documentation you need for using this plugin in your Cordova project.
Select the specific namespace below to open the relevant documentation section:</p>
<ul>
<li><a href="http://ludei.github.io/atomic-plugins-docs/dist/doc/js/Cocoon.Ad.html">Cocoon Ads</a></li>
</ul>
<h3>Full example</h3>
See a full example here: <a href="https://github.com/CocoonIO/cocoon-template-ads"/>Ads demo</a>
* @version 1.0
*/
/**
* Cocoon.Ad class provides an easy to use Ads API that can be used with different Ad providers with built-in support for multiple banners and interstitials.
* @namespace Cocoon.Ad
*/
Cocoon.define("Cocoon.Ad", function (extension) {
"use strict";
/**
* The predefined possible layouts for a banner ad.
* @name Cocoon.Ad.BannerLayout
* @memberOf Cocoon.Ad
* @property {string} TOP_CENTER Specifies that the banner must be shown in the top of the screen and vertically centered.
* @property {string} BOTTOM_CENTER Specifies that the banner must be shown in the bottom of the screen and vertically centered.
* @property {string} CUSTOM Specifies that the uses sets a custom banner position
*/
extension.BannerLayout =
{
TOP_CENTER: "TOP_CENTER",
BOTTOM_CENTER: "BOTTOM_CENTER",
CUSTOM: "CUSTOM"
};
/**
* The predefined possible sizes for a banner ad.
* @name Cocoon.Ad.BannerSize
* @memberOf Cocoon.Ad
* @property {string} SMART Smart banner size according to screen size (Phones and Tablets)
* @property {string} BANNER Standard banner size (Phones and Tablets)
* @property {string} MEDIUM_RECT Medium rectangle size (Phones and Tablets)
* @property {string} LEADERBOARD Leaderboard size (Tablets)
*/
extension.BannerSize =
{
SMART: "SMART",
BANNER: "BANNER",
MEDIUM_RECT: "MEDIUM_RECT",
LEADERBOARD: "LEADERBOARD"
};
/**
* @private
*/
extension.Banner = function (bannerId, serviceName) {
this.id = bannerId;
this.serviceName = serviceName;
this.signal = new Cocoon.Signal();
this.width = 0;
this.height = 0;
this.ready = false;
};
/**
*
* @namespace Cocoon.Ad.Banner
* @example
*
* banner = Cocoon.Ad.createBanner();
*
* banner.on("load", function(){
* console.log("Banner loaded " + banner.width, banner.height);
* banner.show();
* });
*
* banner.on("fail", function(){
* console.log("Banner failed to load");
* });
*
* banner.on("show", function(){
* console.log("Banner shown a modal content");
* });
*
* banner.on("dismiss", function(){
* console.log("Banner dismissed the modal content");
* });
*
* banner.on("click", function(){
* console.log("Banner clicked");
* });
*
* banner.load();
*/
extension.Banner.prototype = {
/**
* Shows the banner ad.
* @memberOf Cocoon.Ad.Banner
* @function show
* @example
* myBanner = Cocoon.Ad.createBanner(settings);
* myBanner.show();
*/
show: function () {
Cocoon.exec(this.serviceName, "showBanner", [this.id]);
},
/**
* Hides the banner ad.
* @memberOf Cocoon.Ad.Banner
* @function hide
* @example
* banner = Cocoon.Ad.createBanner(settings);
* banner.hide();
*/
hide: function () {
Cocoon.exec(this.serviceName, "hideBanner", [this.id]);
},
/**
* Sets a specific layout for a banner ad.
* @memberOf Cocoon.Ad.Banner
* @function setLayout
* @param {Cocoon.Ad.BannerLayout} layout The predefined layout for a banner ad.
* @example
* banner = Cocoon.Ad.createBanner(settings);
* banner.setLayout(layout); // If CUSTOM layout
*/
setLayout: function (layout) {
Cocoon.exec(this.serviceName, "setBannerLayout", [this.id, layout]);
},
/**
* Sets a specific position for a banner ad in CUSTOM layout.
* @memberOf Cocoon.Ad.Banner
* @function setPosition
* @param {number} x The top lef x coordinate of the banner.
* @param {number} y The top lef y coordinate of the banner.
* @example
* banner = Cocoon.Ad.createBanner(settings);
* banner.setLayout(layout); // If CUSTOM layout
* banner.setPosition(x, y);
*/
setPosition: function (x, y) {
Cocoon.exec(this.serviceName, "setBannerPosition", [this.id, x, y]);
},
/**
* Loads a banner ad.
* @memberOf Cocoon.Ad.Banner
* @function load
* @example
* banner = Cocoon.Ad.createBanner(settings);
* banner.load();
*/
load: function () {
Cocoon.exec(this.serviceName, "loadBanner", [this.id]);
},
/**
* Checks if the banner is loaded and ready
* @memberOf Cocoon.Ad.Banner
* @function isReady
* @example
* var ready = banner.isReady();
*/
isReady: function () {
return this.ready;
},
/**
* Triggered when a new banner is loaded.
* @memberOf Cocoon.Ad.Banner
* @event On load
* @example
* banner.on("load", function(){
* console.log("Banner loaded " + banner.width, banner.height);
* });
*/
/**
* Triggered when the loading process of a banner has failed.
* @memberOf Cocoon.Ad.Banner
* @event On fail
* @example
* banner.on("fail", function(error){
* console.log("Banner failed to load: " + JSON.stringify(error));
* });
*/
/**
* Triggered when a new banner is expanded to full screen.
* @memberOf Cocoon.Ad.Banner
* @event On show
* @example
* banner.on("show", function(){
* console.log("Banner shown a modal content");
* });
*/
/**
* Triggered when a banner is collapsed.
* @memberOf Cocoon.Ad.Banner
* @event On dismiss
* @example
* banner.on("dismiss", function(){
* console.log("Banner dismissed the modal content");
* });
*/
/**
* Triggered when a banner is clicked.
* @memberOf Cocoon.Ad.Banner
* @event On click
* @example
* banner.on("click", function(){
* console.log("Banner clicked");
* });
*/
on: function (eventName, handler) {
this.signal.on(eventName, handler);
}
};
/**
* @private
*/
extension.Interstitial = function (interstitialId, serviceName) {
this.id = interstitialId;
this.serviceName = serviceName;
this.signal = new Cocoon.Signal();
this.ready = false;
};
/**
*
* @namespace Cocoon.Ad.Interstitial
* @example
* interstitial = Cocoon.Ad.createInterstitial();
*
* interstitial.on("load", function(){
* console.log("Interstitial loaded");
* });
* interstitial.on("fail", function(){
* console.log("Interstitial failed");
* });
* interstitial.on("show", function(){
* console.log("Interstitial shown");
* });
* interstitial.on("dismiss", function(){
* console.log("Interstitial dismissed");
* });
*
* interstitial.on("click", function(){
* console.log("Interstitial clicked");
* });
*
* interstitial.load();
*/
extension.Interstitial.prototype = {
/**
* Shows the interstitial ad.
* @memberOf Cocoon.Ad.Interstitial
* @function show
* @example
* interstitial = Cocoon.Ad.createInterstitial(settings);
* interstitial.show();
*/
show: function () {
this.ready = false; //true on next load event
Cocoon.exec(this.serviceName, "showInterstitial", [this.id]);
},
/**
* Loads an interstitial ad.
* @memberOf Cocoon.Ad.Interstitial
* @function load
* @example
* interstitial = Cocoon.Ad.createInterstitial(settings);
* interstitial.load();
*/
load: function () {
Cocoon.exec(this.serviceName, "loadInterstitial", [this.id]);
},
/**
* Checks if the interstitial is loaded and ready
* @memberOf Cocoon.Ad.Interstitial
* @function isReady
* @example
* var ready = interstitial.isReady();
*/
isReady: function () {
return this.ready;
},
/**
* Triggered when a new interstitial is loaded.
* @memberOf Cocoon.Ad.Interstitial
* @event On load
* @example
* banner.on("load", function(){
* console.log("Interstitial loaded");
* });
*/
/**
* Triggered when the loading process of an interstitial has failed.
* @memberOf Cocoon.Ad.Interstitial
* @event On fail
* @example
* interstitial.on("fail", function(error){
* console.log("Interstitial failed to load: " + JSON.stringify(error));
* });
*/
/**
* Triggered when a new interstitial is shown.
* @memberOf Cocoon.Ad.Interstitial
* @event On show
* @example
* interstitial.on("show", function(){
* console.log("Interstitial shown");
* });
*/
/**
* Triggered when an interstitial is closed.
* @memberOf Cocoon.Ad.Interstitial
* @event On dismiss
* @example
* interstitial.on("dimissed", function(){
* console.log("Interstitial dimissed");
* });
*/
/**
* Triggered when an interstitial is clicked.
* @memberOf Cocoon.Ad.Interstitial
* @event On click
* @example
* interstitial.on("click", function(){
* console.log("Interstitial clicked");
* });
*/
on: function (eventName, handler) {
this.signal.on(eventName, handler);
}
};
/**
* @private
*/
extension.RewardedVideo = function (rewardedVideoId, serviceName) {
this.id = rewardedVideoId;
this.serviceName = serviceName;
this.signal = new Cocoon.Signal();
this.ready = false;
};
/**
*
* @namespace Cocoon.Ad.RewardedVideo
* @example
* rewardedVideo = Cocoon.Ad.createRewardedVideo();
*
* rewardedVideo.on("load", function(){
* console.log("Rewarded video loaded");
* });
* rewardedVideo.on("fail", function(){
* console.log("Rewarded video failed");
* });
* rewardedVideo.on("show", function(){
* console.log("Rewarded video shown");
* });
* rewardedVideo.on("dismiss", function(){
* console.log("Rewarded video dismissed");
* });
*
* rewardedVideo.on("click", function(){
* console.log("Rewarded video clicked");
* });
*
* rewardedVideo.load();
*/
extension.RewardedVideo.prototype = {
/**
* Shows the rewarded video ad.
* @memberOf Cocoon.Ad.RewardedVideo
* @function show
* @example
* rewardedVideo = Cocoon.Ad.createRewardedVideo(settings);
* rewardedVideo.show();
*/
show: function () {
this.ready = false; //true on next load event
Cocoon.exec(this.serviceName, "showRewardedVideo", [this.id]);
},
/**
* Loads an rewarded video ad.
* @memberOf Cocoon.Ad.RewardedVideo
* @function load
* @example
* rewardedVideo = Cocoon.Ad.createRewardedVideo(settings);
* rewardedVideo.load();
*/
load: function () {
Cocoon.exec(this.serviceName, "loadRewardedVideo", [this.id]);
},
/**
* Checks if the rewarded video is loaded and ready
* @memberOf Cocoon.Ad.RewardedVideo
* @function isReady
* @example
* var ready = rewardedVideo.isReady();
*/
isReady: function () {
return this.ready;
},
/**
* Triggered when a new rewarded video is loaded.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On load
* @example
* banner.on("load", function(){
* console.log("Rewarded video loaded");
* });
*/
/**
* Triggered when the loading process of an rewarded video has failed.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On fail
* @example
* rewardedVideo.on("fail", function(error){
* console.log("Rewarded video failed to load: " + JSON.stringify(error));
* });
*/
/**
* Triggered when a new rewarded video is shown.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On show
* @example
* rewardedVideo.on("show", function(){
* console.log("Rewarded video shown");
* });
*/
/**
* Triggered when an rewarded video is closed.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On dismiss
* @example
* rewardedVideo.on("dimissed", function(){
* console.log("Rewarded video dismissed");
* });
*/
/**
* Triggered when an rewarded video is clicked.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On click
* @example
* rewardedVideo.on("click", function(){
* console.log("Rewarded video clicked");
* });
*/
/**
* Triggered when a video reward is completed.
* @memberOf Cocoon.Ad.RewardedVideo
* @event On reward
* @example
* rewardedVideo.on("reward", function(reward, error){
* if (reward && reward.amount > 0) {
* console.log("Reward completed. Earned " + reward.amount + " items");
* }
* });
*/
on: function (eventName, handler) {
this.signal.on(eventName, handler);
}
};
var idCounter = 0;
extension.AdService = function (serviceName) {
this.serviceName = serviceName;
this.activeAds = {};
};
var proto = {};
extension.AdService.prototype = proto;
/**
* @memberOf Cocoon.Ad
* @function listenerHandler
* @private
*/
proto.listenerHandler = function (args) {
var eventName = args[0];
var adId = args[1];
var params = args.slice(2);
var ad = this.activeAds[adId];
if (ad) {
if (eventName === "load") {
ad.ready = true;
}
else if (eventName === "fail") {
ad.ready = false;
}
if (eventName === "load" && params.length > 0) {
//cache banner size
ad.width = params[0];
ad.height = params[1];
params = params.slice(2);
}
ad.signal.emit(eventName, null, params);
}
};
/**
* @memberOf Cocoon.Ad
* @function init
* @private
*/
proto.init = function () {
if (this.initialized) {
return;
}
Cocoon.exec(this.serviceName, "setBannerListener", [], this.listenerHandler.bind(this));
Cocoon.exec(this.serviceName, "setInterstitialListener", [], this.listenerHandler.bind(this));
Cocoon.exec(this.serviceName, "setRewardedVideoListener", [], this.listenerHandler.bind(this));
this.initialized = true;
};
/**
* Configure default banner and interstitial adUnits.
* @memberOf Cocoon.Ad
* @function configure
* @param {object} [settings] The banner optional settings.
* @example
* //Global configuration
*Cocoon.Ads.configure({
* banner:"agltb3B1Yi1pbmNyDQsSBFNpdGUxxxxxxx",
* interstitial:"agltb3B1Yi1pbmNyDQsSBFNpdGUyyyyyyy"
*})
* //Or platform specific configuration
*Cocoon.Ads.configure({
* ios: {
* banner:"agltb3B1Yi1pbmNyDQsSBFNpdGUxxxxxxx",
* bannerIpad:"agltb3B1Yi1pbmNyDQsSBFNpdGUzzzzz", //optional
* interstitial:"agltb3B1Yi1pbmNyDQsSBFNpdGUyyyyyyy",
* interstitialIpad:"agltb3B1Yi1pbmNyDQsSBFNpdGUtttttt", //optional
* },
* android: {
* banner:"agltb3B1Yi1pbmNyDQsSBFNpdGUwwwwww",
* interstitial:"agltb3B1Yi1pbmNyDQsSBFNpdGUhhhhhh"
* }
*);*
*/
proto.configure = function (settings) {
var platform = Cocoon.getPlatform();
if (platform === Cocoon.PlatformType.AMAZON && settings[Cocoon.PlatformType.ANDROID]) {
//fallback from amazon to android if only android specified
platform = Cocoon.PlatformType.ANDROID;
}
if (settings[platform]) {
settings = settings[platform];
}
Cocoon.exec(this.serviceName, "configure", [settings]);
};
/**
* Creates a banner.
* @memberOf Cocoon.Ad
* @function createBanner
* @param {string} [adUnit] banner adUnit. Taken from cordova settings or configure method if not specified.
* @param {Cocoon.Ad.BannerSize} [size] The banner size. Default value: Smart Size
* @return {Cocoon.Ad.Banner} banner A new banner ad.
* @example
* var banner = Cocoon.Ad.createBanner();
* banner.load();
*/
proto.createBanner = function (adUnit, size) {
this.init();
var bannerId = idCounter++;
Cocoon.exec(this.serviceName, "createBanner", [bannerId, adUnit, size]);
var banner = new extension.Banner(bannerId, this.serviceName);
this.activeAds[bannerId] = banner;
return banner;
};
/**
* Releases the banner given.
* @memberOf Cocoon.Ad
* @function releaseBanner
* @param {Cocoon.Ad.Banner} banner The banner ad to release.
* @example
* Cocoon.Ad.releaseBanner(banner);
*/
proto.releaseBanner = function (banner) {
Cocoon.exec(this.serviceName, "releaseBanner", [banner.id]);
delete this.activeAds[id];
};
/**
* Creates an interstitial.
* @memberOf Cocoon.Ad
* @function createInterstitial
* @param {string} [adUnit] Interstitial adUnit. Taken from cordova settings or configure method if not specified.
* @return {Cocoon.Ad.Interstitial} A new interstitial.
* @example
* var interstitial = Cocoon.Ad.createInterstitial();
* interstitial.load();
*/
proto.createInterstitial = function (adUnit) {
this.init();
var interstitialId = idCounter++;
Cocoon.exec(this.serviceName, "createInterstitial", [interstitialId, adUnit]);
var interstitial = new extension.Interstitial(interstitialId, this.serviceName);
this.activeAds[interstitialId] = interstitial;
return interstitial;
};
/**
* Releases the interstitial given.
* @memberOf Cocoon.Ad
* @function releaseInterstitial
* @param {Cocoon.Ad.Interstitial} interstitial The interstitial to release.
* @example
* Cocoon.Ad.releaseInterstitial(interstitial);
*/
proto.releaseInterstitial = function (interstitial) {
Cocoon.exec(this.serviceName, "releaseInterstitial", [interstitial.id]);
delete this.activeAds[interstitial.id];
};
/**
* Creates a rewarded video (only supported in some networks)
* @memberOf Cocoon.Ad
* @function createRewardedVideo
* @param {string} [adUnit] RewardedVideo adUnit. Taken from cordova settings or configure method if not specified.
* @return {Cocoon.Ad.RewardedVideo} A new rewarded video.
* @example
* var rewardedVideo = Cocoon.Ad.createRewardedVideo();
* rewardedVideo.load();
*/
proto.createRewardedVideo = function (adUnit) {
this.init();
var rewardedVideoId = idCounter++;
Cocoon.exec(this.serviceName, "createRewardedVideo", [rewardedVideoId, adUnit]);
var rewardedVideo = new extension.RewardedVideo(rewardedVideoId, this.serviceName);
this.activeAds[rewardedVideoId] = rewardedVideo;
return rewardedVideo;
};
/**
* Releases the rewarded video given.
* @memberOf Cocoon.Ad
* @function releaseRewardedVideo
* @param {Cocoon.Ad.RewardedVideo} rewardedVideo The rewarded video to release.
* @example
* Cocoon.Ad.releaseRewardedVideo(rewardedVideo);
*/
proto.releaseRewardedVideo = function (rewardedVideo) {
Cocoon.exec(this.serviceName, "releaseRewardedVideo", [rewardedVideo.id]);
delete this.activeAds[rewardedVideo.id];
};
//compatibility for Cocoon.Ad methods
extension.serviceName = "LDAdService";
extension.activeAds = {};
for (var key in proto) {
if (proto.hasOwnProperty(key)) {
extension[key] = proto[key];
}
}
return extension;
});
})();