Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
ad plugin — Gideros Forum

ad plugin

hgvyas123hgvyas123 Guru
edited July 2012 in Plugins
hi guys i have tried my hand on plugin and objc and integrated three ad networks in mhuikit

admob (only banner ad of the size of 320x50)
revmob( popup, full screen and ituneslink ad ) all are based on cpa
leadbolt (appwall and Interstitial ad)

lua code
 
 
require "ui"
 
local myFont = TTFont.new("arial.ttf", 18)
 
local myLeadBoltID = "your leadbolt id"
 
--register from <a href="http://www.leadbolt.com/developers_signup.php?ref=10029307" rel="nofollow">http://www.leadbolt.com/developers_signup.php?ref=10029307</a> 
--ps : if you register from here i will get some referral bonus and that will be not 
--deducted from ur account so plz do it from here <img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/smile.png" title=":)" alt=":)" height="20" />
 
--download their sdk and add to our project also add coretelephony.framework
 
local myAdMobID = "your admob id"
 
--register from <a href="http://www.admob.com/" rel="nofollow">http://www.admob.com/</a> download their sdk and add to our project also add messageui.framework
 
local myRevMobID = "your revmob id"
 
--register from <a href="http://www.revmob.com/" rel="nofollow">http://www.revmob.com/</a> download their sdk and add to our project
 
 
 
 
local function handleEvent(self,event)
	if self:hitTestPoint(event.x,event.y) then
		if self.myName == "hideAd" then
			myAdMob.hideAd()
		elseif self.myName == "showAd" then
			myAdMob.showAd()
		elseif self.myName == "changePos" then
			myAdMob.changePos({xPos=math.random(320),yPos=math.random(320)})
		elseif self.myName == "RevmobPopUp" then
			myRevMob.showPopUp({id = myRevMobID})
		elseif self.myName == "RevmobFullScreen" then
			myRevMob.showFullScreen({id = myRevMobID})		
		elseif self.myName == "revmobItunesAd" then
			myRevMob.iTunesLink({id = myRevMobID})
		elseif self.myName == "leadBoltInterstitial" then
			myLeadBolt.showInterstitial({id = myLeadBoltID})
		elseif self.myName == "leadBoltAppWall" then
			local webview = WebView.new("<a href="http://ad.leadboltads.net/show_app_wall?section_id=992652535&quot" rel="nofollow">http://ad.leadboltads.net/show_app_wall?section_id=992652535&quot</a><img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/wink.png" title=";)" alt=";)" height="20" />
			addToRootView(webview)
			webview:setPosition(0,0)
			webview:setSize(application:getDeviceWidth(),application:getDeviceHeight())
 
			local button = Button.new()
 
			button:setPosition(0, application:getDeviceHeight() - 35)
			button:setSize(100, 30)
 
			button:setTitle("close Me")
			button:setTitleColor(255,0,0)
			--button:setBGColor(1,0,1)
			button:setFont("Verdana",12)
 
			addToRootView(button)
 
			local function closeMe()
				removeFromRootView(webview)
				removeFromRootView(button)
			end
			button:addEventListener("onButtonClick",closeMe,button)
		end
	end
end
 
local hideAd = TextField.new(myFont,"hideAd")
hideAd.myName = "hideAd"
stage:addChild(hideAd)
 
local showAd = TextField.new(myFont,"showAd")
showAd.myName = "showAd"
stage:addChild(showAd)
 
local changePosAd = TextField.new(myFont,"changePos")
changePosAd.myName = "changePos"
stage:addChild(changePosAd)
 
local RevmobPopUp = TextField.new(myFont,"RevmobPopUp")
RevmobPopUp.myName = "RevmobPopUp"
stage:addChild(RevmobPopUp)
 
local RevmobFullScreen = TextField.new(myFont,"RevmobFullScreen")
RevmobFullScreen.myName = "RevmobFullScreen"
stage:addChild(RevmobFullScreen)
 
local revmobItunesAd = TextField.new(myFont,"revmobItunesAd")
revmobItunesAd.myName = "revmobItunesAd"
stage:addChild(revmobItunesAd)
 
local leadBoltBanner = TextField.new(myFont,"leadBoltInterstitial")
leadBoltBanner.myName = "leadBoltInterstitial"
stage:addChild(leadBoltBanner)
 
local leadBoltAppWall = TextField.new(myFont,"leadBoltAppWall")
leadBoltAppWall.myName = "leadBoltAppWall"
stage:addChild(leadBoltAppWall)
 
for i=1,stage:getNumChildren() do
	local sprite = stage:getChildAt(i)
	sprite:setPosition(0,200+i*30)
	sprite:addEventListener(Event.MOUSE_DOWN, handleEvent,sprite)
end
 
myAdMob.initAd({Id = myAdMobID,xPos=0,yPos=0})

note :- it is my first try on objc and plugin so it will be nice if any plugin expert can take a look into it. suggestions are welcome

:)
zip
zip
plugin.zip
13K

Likes: paulocarrasco

Dislikes: aysepinar, Nathan_D, DRS

+1 -1 (+1 / -3 )Share on Facebook

Comments

Sign In or Register to comment.