FusePowered

Got Admob working for Android :)

170 replies [Last post]

Replies

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Oops, I have that global in my app to use different implementations in my game :P I've added the line to the code in post 1 now.

I'll give you a more detailed response to your question so you can understand whats going on...

When you switch to another app (eg. when you click the ad, or press the home button) Android sends your app a suspend message. This tells the app it should sleep.

There are two kinds of suspend:

1) Sleep - program remains in memory but paused.

- You press home, or switch to another app
- Android sends a 'suspend' event
- Corona process is frozen, but the game remains in memory.

- You return to your game
- Android sends a 'resume' event
- Corona process is unfrozen and the game continues from where it left of

Issues: Corona itself actually freezes your game, and resumes it. In some versions of corona this is broken. I use 319 (for reasons in my tutorial page), and although it works fine, it very rarely has a flickering problem with the screen - but that sorts itself out in about 3 or 4 seconds.

The latest daily has an issue with resuming from suspend at the moment

2) Suspend - program it removed from memory.

- You let the screen go to sleep, and wait 5 to 10 seconds
- The phone sends you a 'suspend' event [You should save state]
- The phone send you a 'exit' event [you should exit immediately]
- The phone FORCES you're app to quit if it hasn't already

- You wake up you're phone
- Your app will be launched with a 'resume' event being passed immediately.

Unless you saved your state your game will just launch from the beginning.

Issues: If you have some save file or other form of save state inside your game, your app may be forced to quit mid game. If you're not prepared for this, this score file could end up in a inconsistent state.

You are responsible for saving your state to disk, and reloading it on resume. Corona won't do this for you.

Most devices send the following sequence on waking up from this kind of suspend:

'resume'
'exit'
'suspend'
'exit'
'resume'

God knows why - but this could cause problems in your game too.

---

Tracking the issue:

You can use the system runtime event:

1
2
3
4
5
6
7
8
9
10
11
12
13
local onSystemEvent = function( event )
                if event.type == "applicationSuspend" then
 
                elseif event.type == "applicationExit" then
 
                elseif event.type == "applicationResume" then
 
                elseif event.type == "applicationStart" then
 
                end
end
 
Runtime:addEventListener( "system", onSystemEvent )

Note: Application Start is if you're app is started normally, and not returning from a resume that had previously exited your app.

You can place some print statements in there, and use adb logcat or eclipse's debugger to capture the log output on your device.

Most likely you will have to either place os.exit() inside the suspend condition to cleanly exit and forget about suspend/resume OR you'll have to implement a save state and do it inside the 'suspend' event and quit. Then on resume reload that file.

Or if you just want to support sleep and not suspend. Switch to a different corona version. I highly recommend 319 unless you really need 2.2 only and fast devices. In which case try a version <=525

hope that helps.

droidresearch
User offline. Last seen 22 weeks 2 days ago. Offline
Joined: 25 May 2011

Dear Kam,

Thanks again for your valuable advice and tips.
I have modified your code and use it as follows:

1
2
3
4
5
6
7
8
9
10
local onSystemEvent = function( event )
    if event.type == "applicationSuspend" then
          if (system.getInfo( "environment" ) ~= "simulator")then               
                os.exit(); 
           end
                
        end
end
 
Runtime:addEventListener( "system", onSystemEvent )

This is to enable Corona Simulator to Build the app. It goes into suspend mode when building. Now, when the user touches the ad banner, the suspend function is called and the app/game is killed. This way, when the user touches the back button of the Galaxy Tab it won't cause the FC which I mentioned earlier.
And yes, you are right, Corona does not handle the suspend and resume properly (for Android at least) - it causes the app/game to crash when returning from a web pop up. I'm currently using Build 505. (Build 544 is even worse, any app built with 544 crashes on Galaxy Tab - I have reported the bug case #6487). I tested with the Sample Hello World code and it also crashes when returning from a web popup - this indicates it is a bug with Corona SDK. I wish the Ansca team will fix it because it would be bad for the User to find that the app/game has closed when returning from a web popup. Meanwhile, I will have be content with just closing the app/game when the web pop up is shown.
Official AdMob (and iAds) support from Ansca would be sweet. But alas, I have read about the lawyer-delay issue.

I also modified the main.lua portion as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local isAndroid = "Android" == system.getInfo("platformName");
function DisplayAd(t)
        native.cancelWebPopup()
        timer.performWithDelay(t, function()
                        local adfile = "apple_ad.html"
                        local sizeX = 320 
                        local sizeY = 48
                        --local scale = 1/display.contentScaleY
 
                        if isAndroid then
                                adfile = "android_ad.html" --OK for Droid and Galaxy Tab
                                                                
                                adSpace = native.showWebPopup((display.contentWidth - sizeX)/2, display.contentHeight - display.screenOriginY - sizeY, sizeX, sizeY, adfile, {baseUrl = system.ResourceDirectory, hasBackground = false, urlRequest = showAd_Android})
                        elseif system.getInfo( "environment" ) == "simulator" then
                                adSpace = display.newRect( (display.contentWidth - sizeX)/2, display.contentHeight - display.screenOriginY - sizeY, sizeX, sizeY )
                        end
                        display.getCurrentStage():insert(adSpace, false)
                end
        )
end

Note that I am only building for Android (not iOS). The 1.5 scaling does not work properly for Galaxy Tab and Droid. The ad banner is chopped off on the right. Disabling scaling and using solely the android_ad.html version, solves the issues.

And lastly, thanks a million again for your help and guidance!

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Hmm thats odd about the scaling. Maybe you need to add 2 px for the android version. Are you using portrait or landscape?

I tested the scaling in the android emulator. The issue without it, is that the webpopup will scale with the normal autoscaling in corona, but webkit will only zoom a max of 1.5 by default. Therefore no matter how big your device screen is, the max ad size will be a scale of 1.5.

Without the scaling, the webpopup becomes larger than the ad. The ad loads to the left of the popup and then jumps to the center.

When you say chopped off, do you mean you see scroll bars in the webpopup? How much is chopped off? Can you take a screenshot maybe?

I better fix it in my app if thats the case :)

azone
User offline. Last seen 2 weeks 1 day ago. Offline
Joined: 24 Feb 2010

Hi Kam,
Thank you for the solution! It works nicely on both platforms.

Dusan
http://addictivezone.com

azone
User offline. Last seen 2 weeks 1 day ago. Offline
Joined: 24 Feb 2010

Hi droidsearch,
I have the same issue with FC on my Nexus One (319 build).
I will use the applicationSuspend to solve it temporarily.

BTW: Have you experienced the following issues on your Galaxy Tab?:
http://developer.anscamobile.com/forum/2011/06/22/shifted-screen-galaxy-tab
http://developer.anscamobile.com/forum/2011/06/10/android-touch-problems-galaxy-tab#comment-42316

Please let me know...

Thanks,
Dusan

droidresearch
User offline. Last seen 22 weeks 2 days ago. Offline
Joined: 25 May 2011

Dear Kam,

You can see the ad banner screenshot here:

http://paulmcpd.blogspot.com/2011/06/admob-screenshots.html

I also posed a question about which AdMob Site/App Ad to choose when adding new Admob App/Site? (See the screen shot - also in the above blog, should I choose A, B, or C). Hope you can advice. Thanks :)

Another question (sorry for so many questions ). In the android_ad.html file, there is an option called ama.
Does this refer to AdSense ads? Google has integrated AdSense and AdMob and they are displaying AdSense ads when there is no fill for AdMob. Should I enable ama = true to get AdSense ads.
I could test it out for my next game.

Once again, thanks for reading and taking the trouble to reply and sharing your knowledge :)

Dear dpavlica/Dusan,

I installed your DeviceInfo app on Galaxy Tab.
When run, I get a black screen. Used back button - no response. Use Home button ok. Which Corona built are you using?

I had the same issue with Built 544, and so, now, I use only Built 505.

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Hmm thats strange. I guess the tab doesn't abide by the viewport settings.

With regards to the admob option, you should be using A. Ignore the sdk download. You should also set the refresh rate to 20 seconds. The html file does a refresh every 30 seconds, so this makes sure a new ad is ready on admob's side.

Ama isn't for adsense. Its for a special type of ad used on websites. There should be an option in admob to enable adsense. You need to qualify to have the option enabled. I'm not entirely sure how, but I have it in my account. Other people I know dont :/

mda7
User offline. Last seen 2 years 31 weeks ago. Offline
Joined: 28 May 2011

Kam187 recommended using build 319. The oldest build that I can see on http://developer.anscamobile.com/downloads/daily-builds is build 521.

Is build 319 stored somewhere else on Ansca web site?

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

The link is in section 7 of my tips page:

http://www.base2solutions.com/walkabout/Corona%20Tips.html

samad
User offline. Last seen 39 weeks 2 days ago. Offline
Joined: 25 Dec 2010

Hi there.
I'm trying for about 2 weeks to solve this issue of adding some Ads to an Android (HTC Sense).

But, I always receive a blinking Ad region flipping from left to right very quickly.

Any one got the same issue?

Regards

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

If you use this code, or just want to help me out... please vote for my app here :p 5 seconds literally!

NO NEED to register or anything long like that. Just click this link and then click on the heart to vote.

http://iheartthisapp.com/apps/walkabout/

akviby
User offline. Last seen 43 weeks 1 day ago. Offline
Joined: 20 Jan 2011

I have implemented this solution and in the iOS simulator the webads just flash and dissapear and on the iOS devices it crasches the whole game. Any ideas why it will behave this way?

samad
User offline. Last seen 39 weeks 2 days ago. Offline
Joined: 25 Dec 2010

Hi.
I kept a lot of time trying to figure why that solution does not work for me (and for others).
I made a lot of tests and here are the conclusions that can help others.

1. Type of Ad.
I created in the Admob site 4 types os Ads (Android, WebSmartPhones, WebMobile, iPhone) to see if the behavior changes depending on the type of device.
In all my tests the results always are independent of type of Ad.
I don't know if there are other issues that Admob uses to check if the device is correct, mas the result was always the same.

2. Type of Content Scaling.
I discover that this was the key factor for it to work or not.
Here are the results:
letterBox: Ad trembles from left to right repeatedly (1 or 2 mm).
zoomStretch: Ad trembles from left to right repeatedly (1 or 2 mm).
none: Ad trembles from left to right repeatedly (half screen). very odd presentation.

The only way it works is with zoomEven.

I hope it helps.
Regards

Evna
User offline. Last seen 3 years 7 weeks ago. Offline
Joined: 20 Oct 2010

Hi! Thank you for all your help with all your help so far but I am having a problem. I have everything working great however when I change the test from test: true to test: false and build for my device the adds are still showing as test ads...

Hopefully its something easy to fix... :/

eusebi
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 9 Jun 2011

Hi,

I'm developing a free game and want to test the admob hack to put ads to it. Is there any way to test it before publishing the app in the market/appstore? The key point here is what url tell admob to get the code for the ads...

Thanks in advance and regards

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Som replies to the last few posts...

akviby: There was a bug in one of the dailies causing crashes with the web popup, try again with 319 or the latest

samad: I use letterbox and although the ad shuffles left to right when displayed it doesn't continue to do that. The code is made for landscape orientation, but you can change the displayad function to reposition for portrait if thats what you're using.

Evna: There are several files for different devices (all the ones ending in html). You need to turn test off in all of them. To turn test off, you should change 'true' to 'false'

eusebi: Yes you can and SHOULD test before you publish. The url in admob isn't actually used to verify your app for ads so you can leave it blank for now. Its used by admob to check your site/app if at some point they notice suspicious behaviour in your account - eg lots of ad clicks suddenly. Admob rules specify you are not allowed to put ads too close to buttons to trick people into clicking for example.

Stephen Lewis
User offline. Last seen 13 hours 31 min ago. Offline
Joined: 24 Sep 2010

Hi Kam,

In step 2 you say "...Edit the site and set the refresh rate to 20 seconds..."

I don't see where in my admob dashboard I can set the refresh rate. I know I can do it there if the "site" is an app, but not if it's a website, as far as I can tell. And this admob hack only works using the website admob site, correct?

Any clarification you can provide towards adjusting the ad refresh rate would be appreciated.

And thanks for updating all this info and code!

EDIT/UPDATE:
Never mind. Got it working. I was being dense and thought this was the same technique as the Ludicrous Software admob hack. I didn't realize I can include the html files in my app package as opposed to running them off a web server.

Thanks again!

eusebi
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 9 Jun 2011

Hi, Kam...

First of all, thanks so much for your help.
Anyway, I use exactly the same code of post 1, and no ad is shown. But I see ad requests in my admob account... What can be happenning? (I am very new in these things, so sorry if the question has no sense...)

It is strange, because with the code of ludicroussoftware I do see ads, but none with yours...

Regards

eusebi
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 9 Jun 2011

Sorry, forgot to mention that I'm working on Android 2.3.4...

Regards

eusebi
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 9 Jun 2011

sorry, problem solved... It was me that have the test mode off and did'nt get any real ad... I suppose it is right, because I didn't have tested it much long...
Anyway, I see that the test ad does not fit in the box and some of the borders can not be seen... What can I do to overcome this...
 I'm working on a Samsung Galaxy S 2.3.4

Regards again

eusebi
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 9 Jun 2011

Hi,

Iv'e tested your hack, kam, and it works, but I'm not able to overcome some problems:

1. the banner is always cropped. I use a config.lua file with 800x480 and landscape mode. Does the banner really have only 320x48 pixels? I always see the scroll bars on the sides of the banner...
2. I have some doubts on where to put the banner... My intention was to locate it in the main game screen, but taking into account that banners in non-action screens work better, I've tried to put on screens after finishing a level, but there is a problem. I don't know what happens, but as this screen is passed quickly, it is almost impossible to obtain a real ad from admob, I always have to wait 10-20-30 seconds to obtain an ad... May it be due to a slow network? I don't think so.... Maybe some of you can help me...

Best regards and thanks in advance

gibsonpa
User offline. Last seen 9 weeks 4 days ago. Offline
Joined: 19 Feb 2011

Kam187, been using your admob fix in my app for the last month. While it is working great technically...have you (or anyone else) noticed the lack of ad variety lately? It seems to serve up the same one or two ads (voice change and group texting) nearly 100% of the time. Seems like in the past there was dish, ebay, games, etc that were served up.

The only change I made recently was refreshing the ads every 20 seconds...I left that out originally by accident. I am assuming it is an admob problem...but just wanted to bounce it off the expert =)

osusiandbeer
User offline. Last seen 1 year 18 weeks ago. Offline
Joined: 29 Jun 2011

I'am japanease android developer. English little...

This web page is wonderful.
However, the error was found.

It is admob the error when returning clicking admob however.

--logcat  android

FATAL EXCEPTION: GLThread 11
E/AndroidRuntime( 4974): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=corona:http://c.admob.com/c1/........
E/AndroidRuntime( 4974): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
E/AndroidRuntime( 4974): at

......

act=android.intent.action.VIEW dat=corona:http://c.admob.com/c1/.......

--Cause ? corona:
corona:http://c.admob.com/

string.gsub is not effective ?

--solved

function showAd_Android(event)

-- Is the url a remote call?
if string.find(event.url, "android_ad.html", 1, false) or string.find(event.url, "android_ad15.html", 1, false) then
return true
else
local isCorona = string.sub(event.url, 1,7)
isCorona = string.lower ( isCorona )
if isCorona == "corona:" then
event.url = string.sub(event.url,8)
end

system.openURL(event.url)

...

FireSoft
User offline. Last seen 41 weeks 10 hours ago. Offline
Joined: 18 Jan 2011

I have problem in Android: it doesnt show any ads. I have everything set up, but it just doesnt work. But if i set test: true in html file, i can see test ad. But with test:false i cant see anything. Using latest daily build in Windows and Android 2.3.4

alickgardiner
User offline. Last seen 2 years 31 weeks ago. Offline
Joined: 24 Jun 2011

Got it working for Mobfox by just altering the code a bit (because the mobfox site ads are php-based I host the ad page on my own webserver and call it from there though)

even on the test ad, yeah sometimes appears straight away and sometimes can take quite a while to show, all on a wireless home network to rule out mobile data speeds as an issue

Either way, defeinitely nice having a 3rd option rather than either give your game away free with no monetisation or having to charge for it up front :)

cullenjwebb
User offline. Last seen 3 years 16 weeks ago. Offline
Joined: 14 Apr 2011

Where does one edit the code to reposition the ad space? The size is fine, but I am using landscape and want it in the top left.

The code is great, by the way. I don't see why Corona wouldn't be able to implement this themselves soon. You made it simple enough.

Thanks a bunch!
-Cullen J Webb

guruk
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 9 Feb 2010

hi there,
just asking about the legal aspect?

Adsense closed several user accounts before because they made a html page with no content but ads in it (for example to include in a frame)

this solution here sounds similar. Any knowledge how admob stays to it?
For sure, i would be more than glad should the are cool with it :)

chris

alickgardiner
User offline. Last seen 2 years 31 weeks ago. Offline
Joined: 24 Jun 2011

Not sure about admob, but I emailed mobfox who are very similar and they were fine with it and authorised mine, despite the fact it was again just a page with the ad on to be included as an overlay at the bottom of the game screen

guruk
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 9 Feb 2010

@alickgarnier..
thanks for sharing your experience.. could u also share a demo how you implemented mobfox.

would be great if some can confirm their experience with admob (legal) ...

chris

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

Just want to mention that this code no longer works. showWebPopup doesn't return anything, so you you are actually trying to insert a nil value with this line:
display.getCurrentStage():insert(adSpace, false)

You get "app is corrupted" when trying to run on device.

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

Here is a modified version, compatible with recent releases of Corona and made as a module - name it whatever you want, but don't name it "ads.lua" since this is now reserved by Corona for InMobi and future ad providers. For example, "admob.lua" will do.

I also added the option to show the ad on top of the screen.

However, it looks like the timer workaround for jumping ads in original code doesn't work anymore. When createAd() is call the ad will display normally, then it will quickly shift 2px to the left, then 1px to the right and again 1px to the right, returning to it's normal position. This happens quickly in 2 sec or so and is a minor thing, but if somebody knows how to get rid of this jumping behavior please share a solution here.

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
module(..., package.seeall)
 
local dummy
local isAndroid = "Android" == system.getInfo("platformName")
 
local CW = display.contentWidth
local CH = display.contentHeight
local SOX = display.screenOriginX
local SOY = display.screenOriginY
 
local function round(n)
    return math.floor(n + 0.5)
end
 
local function showAd_Android(event)
    -- Is the url a remote call?
    if string.find(event.url, "android_ad.html", 1, false) then
        return true
    else
        system.openURL( string.gsub(event.url, "Corona:", "") )
        -- Refresh ad
        removeAd()
        createAd()
        return true
    end
end
 
local function showAd_Apple(event)
    -- Is the url a remote call?
    if string.find(event.url, "http://", 1, false) == 1 then
        -- Is it a call to the admob server?
        if string.find(event.url, "c.admob.com", 1, false) ~= nil then
            -- an actual click on an ad, so open in Safari
            system.openURL(event.url)
            -- Refresh ad
            removeAd()
            createAd()
        end
    else
        return true
    end
end
 
function createAd(showOnTop)
    native.cancelWebPopup()
 
    local adfile = "apple_ad.html"
    local sizeX = 320
    local sizeY = 48
    local posX = (CW - sizeX) / 2
    -- round the Y position to remove the 1px gap
    -- between the bottom of the ad the bottom of the screen
    local posY = showOnTop and SOY or round(CH - SOY - sizeY)
 
    if isAndroid then
        adfile = "android_ad.html"
        native.showWebPopup(posX, posY, sizeX, sizeY, adfile,
            {
                baseUrl = system.ResourceDirectory,
                hasBackground = false,
                urlRequest = showAd_Android
            }
        )
 
    elseif system.getInfo("environment") == "simulator" then
        dummy = display.newRect(posX, posY, sizeX, sizeY)
        display.getCurrentStage():insert(dummy, false)
    else
        native.showWebPopup(posX, posY, sizeX, sizeY, adfile,
            {
                baseUrl = system.ResourceDirectory,
                hasBackground = false,
                urlRequest = showAd_Apple
            }
        )
    end
end
 
function removeAd()
    native.cancelWebPopup()
    if dummy then
        dummy:removeSelf()
        dummy = nil
    end
end

guruk
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 9 Feb 2010

hI guys,

really i don't like to spoil your fun with adding admob in web views.
Just let you know that my contact on admob/adsense confirmed 'they' don't allow that!

:what i got from google/admob
>>we don't allow ads to be implemented in the web view, and shown through an app.
>>That applies to AdMob and AdSense.
>>We don't have a solution for developers using web views in apps right now.

I mention that to keep you out of trouble. As from experience (look in forums) they cancelled several developers admob/adsense accounts in the past and the devs lost a lot of money

In that case it may be better to focus on Inmobi (official in Corona) or as 'alickgardiner' mentioned it looks MobFox is fine with implementing ads in that way (i can't confirm).

Take care and best luck!

Chris

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Hey guys.

Sorry been away for a few weeks with work. Here's some replies to various posts. Let me know if I missed anyone...

eusebi: The banner does only have 320x48 pixels, BUT webkit will 'zoom' it up on larger screens. Normally the maximum zoom is 1.5, but in some instances it can be higher.

The code handles resizing the webview automatically, but it may be some themeing difference on your device which causes different behaviour.

Check the two SizeX and SizeY lines, and instead of +1 try +2

The only issue with making this value too large is that the ad jumps more on first load.

With regards to your second problem - as far as I know its not possible to preload the webview, since it only loads when you display it. The Webview is always on top too, so you cant even burry it behind an image and preload it there.

What you could try is to open the webpopup OFF screen before the end of the level and move it ON screen when you hit the end of the level.

Be careful with this tho, as opening web popups off screen for impressions wont make admob too happy. But if you open it 3 or 4 seconds before i'm sure thats fine.

One last thing, I personally found that ads in game worked a lot better than on menu screens and level pages between levels.

--

cullenjwebb: The position of where the webpopup is, is in the webpopup call:

(display.contentWidth - sizeX)/2, display.contentHeight - display.screenOriginY - sizeY, sizeX, sizeY

Here, x is (display.contentWidth - sizeX)/2, or the display width minus the webpopup size, divided by two. Or in other words centred X on the screen
Here, y is (display.contentHeight - display.screenOriginY - sizeY, or the height of the screen + the letterbox area (to find the bottom of the screen) minus the webpopup height.

The -display.screenOriginY is a bit misleading, but OriginY gives you the size of the top letterbox, which will be negative, while the bottom one should be positive. Thats why you - instead of +.

If you want it in the top left you would probably use:

x = -display.OriginX + SizeX/2
y = display.OriginY + sizeY/2

--

guruk: I've been using it without problems since March. Also when it comes to mobile devices, this is actually what this code is for.

EDIT: I just saw chris's post, and I'm a bit baffled by that. The admob page itself suggests its for web apps :/ Perhaps they don't want to oficially say you can do that so they can revoke your account if you do something silly with it.

--

vitally: oops :) You only ever need that insert for the simulator to insert the Rect to the top. I guess it just happen to work before because showWebPopup returned a non nil value. I've edited my first post to move that line inside the 'simulator' if block.

With regards to the ad jumping around - This is the admob script itself trying to centre the add in the structure or frame its in. Since the script itself is a giant anonymous function there's no way to override that function without duplicating it locally. I decided against duplicating their function locally as they could at any stage change the embedded url or some other parameter they use. I only override the click event so we can catch it in corona. The original code only implements the timer to allow you to delay showing the webpopup. I use it in my game so I left it in there. You could of course do the same by using performWithDelay yourself.

guruk
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 9 Feb 2010

@kam187
as mentioned i just wrote to keep you out of trouble.
I am several years in that business and some things work nice for 'a while' till they stop it, than the users scream out they they came stolen money (sometimes they loose several thousand dollars)

WEB Mobile Ads are for WebPages that are most seen on mobiles. But and thats the point, the page 'where the ads are included" needs relevant content, wherein they can search for keywords and make the ads relevant for the users and profitable for the advertiser.

I agree that it would be the best way as you do, because we could change ads and ad networks without uploading the app again :)

Take care, my interest is you are on the safe side, thats it. Would be cool Carlos or anyone else could get an official "OK" for that. I will jump on the train immediately :)

greets
chris

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

@kam187 I think I'm missing something. The timer just calls showWebPopup with delay and centering of the ad happens after showWebPopup was called. Unless you can showWebPopup and make it visible after a delay when the ad is already centered.
Could you explain how this works?

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

From my understanding embedding a page inside your app that loads the admob .js either for a web app or otherwise is what this script is for. I _thought_ hosting the web page and loading it remotely was a no-no.

It seems its all grey :P

Having said that i've been using it since march, and a number of other engine like appcelerator to name one, have been doing this forever :/

shark.androidlab
User offline. Last seen 1 year 24 weeks ago. Offline
Joined: 20 Jun 2011

I'm not able to make it working on 2.3, it only blink 1 second when i call the function and nothing else.

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Has anyone else noticed admob fill rates have dropped ALOT, especially on android. I'm seeing something like 17 to 20% :/

Even on iOS its only 50%.

samad
User offline. Last seen 39 weeks 2 days ago. Offline
Joined: 25 Dec 2010

Since Sep, 5 that Fill Rate on 2 of my app's are near 5%.
No answers from Admob.

Anyone has any idea why?

droidresearch
User offline. Last seen 22 weeks 2 days ago. Offline
Joined: 25 May 2011

It has been less than 20% fill rate for me all this while. InMobi is also the same for me (less than 20%). And for me, InMobi takes days (I wonder why) to approve an app for their ads, whilst AdMob does not require approval. Ansca really need to support AdMob if we are going to see better fill rates and better monetization. We really need AdMob SDK integration.

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

Totally missed your post there vitalyx for some reason.

The only thing I think you could do it display the webpopup out of the screen, and then bring it into view (change x,y) once its loaded and centered. You can use some JS (look at the admob help page) to check when/if the ad is loaded. Maybe you can send a callback somehow to corona to let it know its ready.

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

Thanks for your reply, kam187. Man, these ads are frustrating.
AdMob is not officially supported and InMobi also has it's share of deal breaking issues. So I decided to go the old way once again. It has always worked well for me.

kbradford
User offline. Last seen 9 weeks 3 days ago. Offline
Joined: 16 Aug 2011

I'm using this code to display ads and it seems to be working pretty well. The only thing that's odd is I'm getting a huge amount of Requests according to AdMob. Just in the last 2 hours I have 2500+ requests and I am the only one with the app installed, and I only ask for a request in between levels.

Any ideas why my request count is so high?

tuxzilla
User offline. Last seen 3 years 2 weeks ago. Offline
Joined: 7 Sep 2010

what do you guys think of this announcement? http://techcrunch.com/2011/09/03/admob-to-stop-serving-ads-to-mobile-web-google-pushes-developers-to-use-adsense/

Does it put a stop on the hack?

stoleggen
User offline. Last seen 3 years 9 weeks ago. Offline
Joined: 16 Aug 2011

I'm having trouble with this. I think i am pretty close tho. First of all, the ads wont show up. I can only see flickering for about 1 sec. when i start my app. Second, the fillrate is about 30%. Please help.

shark.androidlab
User offline. Last seen 1 year 24 weeks ago. Offline
Joined: 20 Jun 2011

Vitalyx are your admob ads working right now?

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

@shark.androidlab I decided not to go with ads, but haven't seen any sales during the past 3 days. So I'll be releasing ad supported version soon, going with InMobi first.
Android was a big surprise. My sales of stock market app for webOS are doing waaaaay better two years after I released it and that's on a niche and *dead* platform. Ridiculous!

vitalyx
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 11 Apr 2011

Has anyone tried clicking on their own ads to check if they work?
I just did and here is what I see:

Redirect doesn't work, apparently. Any idea why this can be?

droidresearch
User offline. Last seen 22 weeks 2 days ago. Offline
Joined: 25 May 2011

I have stopped using this AdMob hack. For the first time, my AdMob payout for last month was delayed. After writing in to remind them, only, did they make payment after a week. Each app was fetching thousands of requests each day although the number of new installs is less than a 100 for each app. Also the fill rate was less than 20%. I figured probably the extremely high requests triggered some alarm bells with the AdMob team. So be careful guys.

Official AdMob integration into Corona is still nowhere in sight. Sad.

kam187
User offline. Last seen 24 weeks 3 days ago. Offline
Joined: 10 Sep 2010

My requests seem pretty consistant over the last month, but impressions are terrible. Fill rates are around 20 to 30%. I've asked around and its just admob in general.

I got a delayed payout email too, and then they just paid a week or so later.

Looks to me like admob is going to shit. I'd use inMobi for now at least.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.