Difference between revisions of "Ads"

From GiderosMobile
Line 43: Line 43:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/Ads.new|Ads.new]] ''<translate>initializes new ad framework</translate>''<br/><!-- GIDEROSMTD:Ads.new -->
+
[[Special:MyLanguage/Ads.new|Ads.new]] ''<translate>initializes new ad framework</translate>''<br/><!-- GIDEROSMTD:Ads.new(adframework) initializes new ad framework -->
[[Special:MyLanguage/Ads:enableTesting|Ads:enableTesting]] ''<translate>enable testing ads</translate>''<br/><!-- GIDEROSMTD:Ads:enableTesting -->
+
[[Special:MyLanguage/Ads:enableTesting|Ads:enableTesting]] ''<translate>enable testing ads</translate>''<br/><!-- GIDEROSMTD:Ads:enableTesting() enable testing ads -->
[[Special:MyLanguage/Ads:get|Ads:get]] ''<translate>gets property value of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:get -->
+
[[Special:MyLanguage/Ads:get|Ads:get]] ''<translate>gets property value of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:get(property) gets property value of the ad -->
[[Special:MyLanguage/Ads:getHeight|Ads:getHeight]] ''<translate>gets the height of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getHeight -->
+
[[Special:MyLanguage/Ads:getHeight|Ads:getHeight]] ''<translate>gets the height of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getHeight() gets the height of the ad -->
[[Special:MyLanguage/Ads:getPosition|Ads:getPosition]] ''<translate>gets x and y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getPosition -->
+
[[Special:MyLanguage/Ads:getPosition|Ads:getPosition]] ''<translate>gets x and y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getPosition() gets x and y position of the ad -->
[[Special:MyLanguage/Ads:getWidth|Ads:getWidth]] ''<translate>gets width of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getWidth -->
+
[[Special:MyLanguage/Ads:getWidth|Ads:getWidth]] ''<translate>gets width of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getWidth() gets width of the ad -->
[[Special:MyLanguage/Ads:getX|Ads:getX]] ''<translate>gets x position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getX -->
+
[[Special:MyLanguage/Ads:getX|Ads:getX]] ''<translate>gets x position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getX() gets x position of the ad -->
[[Special:MyLanguage/Ads:getY|Ads:getY]] ''<translate>gets y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getY -->
+
[[Special:MyLanguage/Ads:getY|Ads:getY]] ''<translate>gets y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:getY() gets y position of the ad -->
[[Special:MyLanguage/Ads:hideAd|Ads:hideAd]] ''<translate>hides ads</translate>''<br/><!-- GIDEROSMTD:Ads:hideAd -->
+
[[Special:MyLanguage/Ads:hideAd|Ads:hideAd]] ''<translate>hides ads</translate>''<br/><!-- GIDEROSMTD:Ads:hideAd() hides ads -->
[[Special:MyLanguage/Ads:set|Ads:set]] ''<translate>sets property value of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:set -->
+
[[Special:MyLanguage/Ads:set|Ads:set]] ''<translate>sets property value of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:set(property,value) sets property value of the ad -->
[[Special:MyLanguage/Ads:setAlignment|Ads:setAlignment]] ''<translate>sets alignment of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setAlignment -->
+
[[Special:MyLanguage/Ads:setAlignment|Ads:setAlignment]] ''<translate>sets alignment of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setAlignment(horizontal,vertical) sets alignment of the ad -->
[[Special:MyLanguage/Ads:setKey|Ads:setKey]] ''<translate>set keys for the framework</translate>''<br/><!-- GIDEROSMTD:Ads:setKey -->
+
[[Special:MyLanguage/Ads:setKey|Ads:setKey]] ''<translate>set keys for the framework</translate>''<br/><!-- GIDEROSMTD:Ads:setKey(...) set keys for the framework -->
[[Special:MyLanguage/Ads:setPosition|Ads:setPosition]] ''<translate>sets position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setPosition -->
+
[[Special:MyLanguage/Ads:setPosition|Ads:setPosition]] ''<translate>sets position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setPosition(x,y) sets position of the ad -->
[[Special:MyLanguage/Ads:setX|Ads:setX]] ''<translate>Sets x position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setX -->
+
[[Special:MyLanguage/Ads:setX|Ads:setX]] ''<translate>Sets x position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setX(x) Sets x position of the ad -->
[[Special:MyLanguage/Ads:setY|Ads:setY]] ''<translate>sets y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setY -->
+
[[Special:MyLanguage/Ads:setY|Ads:setY]] ''<translate>sets y position of the ad</translate>''<br/><!-- GIDEROSMTD:Ads:setY(y) sets y position of the ad -->
[[Special:MyLanguage/Ads:showAd|Ads:showAd]] ''<translate>display ad</translate>''<br/><!-- GIDEROSMTD:Ads:showAd -->
+
[[Special:MyLanguage/Ads:showAd|Ads:showAd]] ''<translate>display ad</translate>''<br/><!-- GIDEROSMTD:Ads:showAd(...) display ad -->
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
[[Special:MyLanguage/Event.AD_ACTION_BEGIN|Event.AD_ACTION_BEGIN]]<br/><!-- GIDEROSEVT:Event.AD_ACTION_BEGIN -->
+
[[Special:MyLanguage/Event.AD_ACTION_BEGIN|Event.AD_ACTION_BEGIN]]<br/><!-- GIDEROSEVT:Event.AD_ACTION_BEGIN adActionBegin-->
[[Special:MyLanguage/Event.AD_ACTION_END|Event.AD_ACTION_END]]<br/><!-- GIDEROSEVT:Event.AD_ACTION_END -->
+
[[Special:MyLanguage/Event.AD_ACTION_END|Event.AD_ACTION_END]]<br/><!-- GIDEROSEVT:Event.AD_ACTION_END adActionEnd-->
[[Special:MyLanguage/Event.AD_DISMISSED|Event.AD_DISMISSED]]<br/><!-- GIDEROSEVT:Event.AD_DISMISSED -->
+
[[Special:MyLanguage/Event.AD_DISMISSED|Event.AD_DISMISSED]]<br/><!-- GIDEROSEVT:Event.AD_DISMISSED adDismissed-->
[[Special:MyLanguage/Event.AD_ERROR|Event.AD_ERROR]]<br/><!-- GIDEROSEVT:Event.AD_ERROR -->
+
[[Special:MyLanguage/Event.AD_ERROR|Event.AD_ERROR]]<br/><!-- GIDEROSEVT:Event.AD_ERROR adError-->
[[Special:MyLanguage/Event.AD_FAILED|Event.AD_FAILED]]<br/><!-- GIDEROSEVT:Event.AD_FAILED -->
+
[[Special:MyLanguage/Event.AD_FAILED|Event.AD_FAILED]]<br/><!-- GIDEROSEVT:Event.AD_FAILED adFailed-->
[[Special:MyLanguage/Event.AD_RECEIVED|Event.AD_RECEIVED]]<br/><!-- GIDEROSEVT:Event.AD_RECEIVED -->
+
[[Special:MyLanguage/Event.AD_RECEIVED|Event.AD_RECEIVED]]<br/><!-- GIDEROSEVT:Event.AD_RECEIVED adReceived-->
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 15:31, 13 September 2018


Supported platforms:
Available since: Gideros 2011.6
Inherits from: EventDispatcher

Description

The idea is to provide common Ads interface for most of available ad frameworks, so that user's would not have to create a plugin for each of them separately, but rather it would be possible to wrap ad framework in single Java or Objective-C class (depending on the platform) and add it to the project, without even recompiling existing Ads Interface plugin.

Additionally it would be able to support multiple ad frameworks simultaneously so users could switch and fall back between ad frameworks on runtime.

More information available in [1](Ads interface guide).

Examples

Creating fallbacks with Ads frameworks

--require plugin
require "ads"

--initialize amazon
amazon = Ads.new("amazon")
amazon:setKey("amazon-key")

--initialize admob
admob = Ads.new("admob")
admob:setKey("admob-key")

--if amazon fails
--show admob
amazon:addEventListener(Event.AD_FAILED, function(e)
	print("amazon AD_FAILED", e.error)
	admob:showAd("auto")
end)

--if admob fails
--show amazon
admob:addEventListener(Event.AD_FAILED, function(e)
	print("admob AD_FAILED", e.error)
	amazon:showAd("auto")
end)

--start displaying amazon ads
amazon:showAd("auto");

Methods

Ads.new initializes new ad framework
Ads:enableTesting enable testing ads
Ads:get gets property value of the ad
Ads:getHeight gets the height of the ad
Ads:getPosition gets x and y position of the ad
Ads:getWidth gets width of the ad
Ads:getX gets x position of the ad
Ads:getY gets y position of the ad
Ads:hideAd hides ads
Ads:set sets property value of the ad
Ads:setAlignment sets alignment of the ad
Ads:setKey set keys for the framework
Ads:setPosition sets position of the ad
Ads:setX Sets x position of the ad
Ads:setY sets y position of the ad
Ads:showAd display ad

Events

Event.AD_ACTION_BEGIN
Event.AD_ACTION_END
Event.AD_DISMISSED
Event.AD_ERROR
Event.AD_FAILED
Event.AD_RECEIVED

Constants