How to get the view controller for Admob

Hi.
I have follow “ads with AdMob” page to do.
http://forum.unity3d.com/threads/16668-ads-with-AdMob/page2?highlight=admob

Pass the compiler, but still have a problem:
The AdMob SDK requires a valid view controller to be returned from currentViewController AdMobDelegateProtocol). Cancelling ad request.

I understand why have this error, and I spending lot of time to find solve information,
but I’m not good at Object-C. I do not know how to get unity’s view controller.
Who can help me solve this problem!
This files can help for debug >>> 460822–16142–$code&Error.zip (138 KB)

Thanks very much!

A few tips to other friends in need:
I use Unity 3.1 / Admob 2010-11-08 / xCode 3.2.5 / iOS4.2 to building

  1. Use libAdMobNoThumb.a.
  2. Set ‘iOS Deployment Target’ to ‘iOS 3.0’

that means that either a function is not fully implemented or that the result becomes invalid as the error implies that the class that implements the AdMobDelegateProtocol does not provide a valid view controller when its requested to do so.

I have attached the source code.
Can you help me solve it?
Greatly gratitudes.

From looking over the code, it seems you’re never actually allocating a “UIViewController”, so your returning a nil value from “currentViewControllerForAd”

Try something like:

_uiViewController = [[UIViewController alloc] init];

inside:

applicationDidFinishLaunching

Also, the way I add subviews to Unity window, is to use:

[[[UIApplication sharedApplication] keyWindow] addSubview:myView];

HTH

Thank you, DGuy (David).
I tried your method to modify the code, and finally it is succeeded.
admob is running on the unity3.1.

But still a small problem,
I can not set the test mode (admob), this code looks like no working.

  • (NSArray *) testDevices {return [NSArray arrayWithObjects: ADMOB_SIMULATOR_ID, nil];}
  • (NSString *) testAdActionForAd: (AdMobView *) adMobView {return @ “url”;}

It does not matter, the main problem has been resolved.
I want to thank you once again for your help.

I attached the fixed code. be a reference if need

I have the same problem but I can’t get the fixed code attached, could you attach it again?

Thanks in advance!

EDIT: I managed to solve it! Thanks for the bone!

Hey Genes would you please share the working thing? as i am also having some problem in it… thanks in advance…

EDIT: i guess em done with it… will be uploading my working version soon…

hi there.

I can solve the same thing, but it can not move web linked banner. app link is OK.
any idea?

Thanks.

hi i do it i want to study the demo but fixed code have error! i am sorry,my english is poor