How to show AdMob ads in real iPhone device? - iphone

I want to integrate AdMob ads in my iPhone app. I'm using IB way to add the view and follow AdMob's pdf guide:
1. Add AdMob group(AdMobView.h,AdMobDelegateProtocol.h,libAdMob.a)
2. Add required frameworks(AudioToolbox,MediaPlayer,MessageUI,QuartzCore)
3. Add TouchJSON group
4. Add IBSupport group(AdViewController.h,AdViewController.m)
5. Add a 320*48 UIView in IB, add NSObject and change its class to AdViewController,
link AdViewController's view to the 320*48 UIView and link AdViewController's viewController to current view controller.
Now the iPhone simulator can show ads from AdMob, but when I test it on real device, I get the error "AdMob: Did fail to receive ad".
I've tried to add test device's UDID to testDevices array, but still get the same error.
- (NSArray *)testDevices {
return [NSArray arrayWithObjects: ADMOB_SIMULATOR_ID, DEVICE_UDID, nil];
}
Is there any problem in the above steps? Does anybody know why can't I get the ads in real device? By the way, what should be changed to build for real for-sale app, not just for test?

Setting testDevices seems not working for my test device. I've added a deprecated method -(BOOL)useTestAd according to AdMob wiki and it works now.
- (BOOL)useTestAd {
return NO;
}

Related

how to configure iad adds adwhirl for iphone

i have configure adwhirl in my app but add's are not displayed is there any configuration needed in apple account for iad ? if needed any settings for iad in apple account then please guide me and also tell me how to configure that settings in adwhirl.
To use AdWhirl in ur application , you need to register here :
https://www.adwhirl.com/home/register
From here you'll get a unique key.Download the API for Adwhirl and then integrate the key to it.The Adwhirl manages iAd, admob etc. percentage wise.When one fails to load , the adwhirl loads the another.
you can refer this link also :
http://www.raywenderlich.com/5350/how-to-integrate-adwhirl-into-a-cocos2d-game
You might want to consider using the new Admob mediation instead as I believe adwhirl will soon become unsupported as they are concentrating on AdMob now (both owned by google).
Refer this to integrate adwhirl for iad and other ads.
Add iad account on adwhirl account of yours by loging to adwhirl
Download latest AdwhirlAPI and add to your project. Refer Api and setup links
In .h of yourcontroller
#interface yourController : <AdWhirlDelegate>
Now Do following things in .m file where u wnat adwhirl:
1) DefineAdwhirlKey
#define kSampleAppKey #"your adwhirl key"
2) Add code in viewDidLoad
AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[awView setFrame:CGRectMake(0,326,320,50)];//set your frame
[awView setDelegate:self];
[self.view addSubview:awView];
3) Add AdwhirlDelegate methods
- (NSString *)adWhirlApplicationKey
{
return kSampleAppKey;
}
- (UIViewController *)viewControllerForPresentingModalView
{
return self;
}

Will iAds be loaded, if I hide the ADBannerView?

I know Apple recommends just placing the adview offscreen,
incase there is an error, loading an iAd,
but I would like to hide it using [adView setHidden: YES];.
If I do so, will the view check for new ads available?
In the simulator sure it will load the Test Ads,
but will it also work after releasing the app onto actual devices from the AppStore?
SideSwipe
Yes, it should work on real device.

AdWhirl integration problem in iPhone app

I have to implement AdWhirl in my app. It works fine - I'm getting ads from AdMob and iAd now.
There is no ad coming from AdMod and iAd. I am getting an error in the console. I can provide the code I'm using if it'd be helpful.
Try by implementing this delegate...
- (UIViewController *)viewControllerForPresentingModalView
{
return yourAPP.viewController;
}

iPad rotation bug when using MPMoviePlayerViewController

Issue summary
Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810
Sample project
I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player
NSURL *movieUrl = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];
The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master
Steps to reproduce
Obtain the project using the information above
Launch the project with the iPad simulator or device
Tap the button to begin playing the video
Rotate the iPad by 90 degrees
Dismiss the video
Note the UIStatusBar is out of sync with the application UI
Objective
I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.
Successful response from Apple Developer Technical Support!
This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.
You will need to implement this in the view controller which presents the movie player.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self performSelector:#selector(fixStatusBar) withObject:nil afterDelay:0];
}
- (void)fixStatusBar {
[[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}
While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.
This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.
This also solves an iPhone/iPodTouch rotation issue that I was struggling with. I am developing a universal app in which each view displays a different image depending on whether the device is in portrait or landscape orientation. Buttons are used to navigate between views.
If the app is running on the device and a portrait view is rotated to landscape, my image switching takes place. If the device is then placed flat on a table top and the button is tapped to display the next view, the view appears in landscape but shows the portrait image instead. I solved the problem by forcing a portrait view to appear by detecting for face up and down, but Apple's code solved this problem (as well as the similar movie problem I was also experiencing).
Many thanks for reporting the bug - I assumed it was just my bad coding...

always returns nil in iPhone

I am trying to apply Mike Chen's answer here, using SDK 3.0. In delegate.m file I implement;
[viewController.view addSubview:[[objc_getClass("PLCameraController") sharedInstance] previewView]];
and in viewcontroller.m I implement:
PLCameraController *cam = [objc_getClass("PLCameraController") sharedInstance];
CapturedImage = [cam _createPreviewImage];
but 'cam' is always nil. Any suggestions?
This won't work when running in the simulator or on an iPod Touch. Are you running this on a physical iPhone with a camera?
Also, if you've dumped the headers correctly, you shouldn't be using the objc_ runtime functions, but rather using the class names. Is the result of objc_getClass("PLCameraController") set to nil?
On a side note: I hope you're not looking to publish your application through the App Store because this sort of private method calling is a great excuse for Apple to reject your application.
To use PLCameraController, you'll need to include the PhotoLibray private framework. The simplest way to do that is drag drop an Image Picker Controller (UIImagePickerController) into your main nib.