mobile ads problem

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

mobile ads problem

Post by vedus » Fri Mar 21, 2014 10:32 pm

i am try to figure out what i do wrong here and the ads NO working at all
the error i catch is "could not create ad"
both in android phone and the ipad.
here is the code

Code: Select all

local tDetails
 MobileAdRegister "my-registered-code"
on opencard 
  #Advertising  
  if the environment = "mobile" then
    // See the dictionary for more metadata entries
    put "10" into tDetails["refresh"] // The advert refresh interval in seconds
    put 16 into tDetails["age"] // The age of the target audience
    put "female" into tDetails["gender"] // The expected gender of the target audience   
    mobileAdCreate "myAd1","banner",(0,0),tDetails
    put the result into rslt --< Check the error
    if rslt is not empty then
      answer error rslt
      
      //mobileAdSetTopVisible ("myAd1", true) //  Sets the visible of the ad "myAd1" 
      mobileAddSetVisible "myAd1",true
    end if
  end if

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobile ads problem

Post by Klaus » Sat Mar 22, 2014 1:13 pm

Hi vedus,

nbot sure, never worked with ads on mobile yet, but the handler "MobileAdRegister"
should not be listed separately, then is is not being executed!
Put it into a "pre-/openstack" handler or something and try again.

Code: Select all

on preopenstack 
   MobileAdRegister "my-registered-code"
   ##...
end preopenstack
Also set the "mobileAddSetVisible" ONLY in case of success!
You currently do this when it fails 8-)

Code: Select all

local tDetails
on opencard 
  #Advertising 

  # I always avoid long IF END IFs if possible ;-) 
  if the environment <> "mobile" then
     exit opencard
  end if

  ## See the dictionary for more metadata entries
  put "10" into tDetails["refresh"] // The advert refresh interval in seconds
  put 16 into tDetails["age"] // The age of the target audience
  put "female" into tDetails["gender"] // The expected gender of the target audience   
  mobileAdCreate "myAd1","banner",(0,0),tDetails
  put the result into rslt --< Check the error

  ## ERROR! Don't continue!
  if rslt <> empty then
      answer error rslt
     EXIT TO TOP
  end if
      
  ## SUCCESS!
  ## NOW you can set the visible etc...
  ##mobileAdSetTopVisible ("myAd1", true) //  Sets the visible of the ad "myAd1" 
  mobileAddSetVisible "myAd1",true
end opencard
Best

Klaus

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile ads problem

Post by vedus » Sat Mar 22, 2014 6:21 pm

thx klaus,like always you have right :)
question..
i have a top bar and i want the ads to be bellow the top bar but....
because the app is for multi-resolution i can't make it to work.
the height of the bar is 90px so when i put.

Code: Select all

set the topleft of "banner" to the bottomleft of grp "topbar"  # Is no working >the same if i change the "myAd1" with "banner"
if i put

Code: Select all

mobileAdSetTopLeft "myAd1", (0,the bottomleft of grp "topbar") # still no working > the same if i change the "myAd1" with "banner"
anyone have a solution of this?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobile ads problem

Post by Klaus » Sat Mar 22, 2014 6:26 pm

Maybe doing this right from the start:
...
mobileAdCreate "myAd1","banner",(0,90),tDetails
...
? 8)

vedus
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 153
Joined: Tue Feb 26, 2013 9:23 am

Re: mobile ads problem

Post by vedus » Sat Mar 22, 2014 6:31 pm

Klaus wrote:Maybe doing this right from the start:
...
mobileAdCreate "myAd1","banner",(0,90),tDetails
...
? 8)
i have done this before.is no working..in the iphone 320x480 when i put the above code the ads,is on the middle of phone,in the ipad is on the bottom :D
check the attach screen (the black banner)
Screen Shot 2014-03-22 at 7.31.09 PM.png

Post Reply