Admob showing ads in simulator but not in device - ios

This is the code that I am currently using to show some ads on my device. But it doesn't seem to work as of now. Need some guidance on what could be going wrong here.
self.adBanner = [[GADBannerView alloc]
initWithFrame:CGRectMake(0,468,320,50)];
self.adBanner.adUnitID = #"a153b29f919d822";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
//self.adBanner.center = CGPointMake(self.view.center.x, self.adBanner.center.y);
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[self.adBanner loadRequest:r];
Thanks.

If you have recently setup up your account in Google AdMob, it is going to take sometime for the ads to start appearing on the device.
But you can try setting testDevices in your GADRequest. The device Id will be being printed out in your console by the AdMob SDK.
Then add the below code.
r.testDevices = #["test_device_id"];

Related

Is there any delegate methods to hide google Ads without add button to hide Ad Objective c?

I am working on Bottom Banner Ad in table view.It's working fine but client wants to delete the ad when they don't need.So How can I do this???can you give me a suggesstion or code when i try to delete tha ad it's not deleted see my code and image below:
GADRequest *request = [GADRequest request];
self.bannerview = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
self.bannerview.adUnitID = #"ca-app-pub-4719922286387557/3468269154665";
self.bannerview.rootViewController = self;
[self.navigationController.toolbar addSubview:self.bannerview];
[self.bannerview loadRequest:request];

adViewWillDismissScreen in GADBannerViewDelegate is not called

I created GADBannerView and register the view controller as GADBannerViewDelegate.
However I cannot make these two methods (adViewWillDismissScreen and adViewDidDismissScreen) call. Only adViewWillPresentScreen is called
I've followed the url http://googleadsdeveloper.blogspot.com/2014/05/google-mobile-ads-sdk-note-on-ad-click.html
on both Simulator and iOS device. The two methods still not get called.
The below is my code.
self.mBannerView1 = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, 100)];
self.mBannerView1.adUnitID = kMyAdUnitID;
self.mBannerView1.rootViewController = self;
self.mBannerView1.delegate = self;
[self.mBannerView1 loadRequest:request];
[self.view addSubview:self.mBannerView1];

Admob 6.8.0: manually remove, hide or disable banners

There are tons of similar questions here, but none of the solutions are working on the latest AdMob SDK. At least I couldn't make it work.
Loading:
- (void)AdMob_Banner_On
{
bannerView_.adUnitID = kAdMobID;
bannerView_.rootViewController = self;
[bannerView_ loadRequest:[GADRequest request]];
(...)
}
They are running perfectly, and now removing... all solutions I found are quite simple, but they don't work:
- (void)AdMob_Banner_Off {
NSLog(#"Admob: Turning Off");
bannerView_.hidden = YES;
[bannerView_ removeFromSuperview];
[bannerView_ setDelegate:nil];
bannerView_ = nil;
}
Some times I need all screen available, I can't show ads all the time. Any ideas?
In case anyone has the same problem, here is how I fix it.
The problem was that I was that the lines on the "AdMob_Banner_On" method were inverted.
Although the banner was showing up perfectly, it made the bannerView_ unable to respond to any other command, so even if the AdMob_Banner_Off was called, nothing was happening.
Now the code that works. The first thing you should do it to set the position of the banner, and then calling it. That was my problem. This code should work fine:
Turning on:
- (void)AdMob_Banner_On {
NSLog(#"Admob: Turning On");
// Making it on the bottom:
CGPoint origin = CGPointMake(0.0,self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait origin:origin];
bannerView_.adUnitID = kAdMobID;
bannerView_.rootViewController = self;
bannerView_.delegate = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
}
- (void)AdMob_Banner_Off: {
NSLog(#"Admob: Turning Off");
[bannerView_ removeFromSuperview];
}
With this code you can turn on and off the banner as you want. This is useful to apps that can't show the banner all the time.
initAd must be in viewDidLoad
I solved by it.

Admob Banner doesn't show

I want to implement Admob into an app for iPad in landscape mode, I followed step by step tutorial for admob, on adding advertising to the app. I added all the frameworks and requirements given to work correctly.
I can't see the banner. I tried both the simulator and on the device itself. According to the following link it seems that:
"Test ads are not supported on iOS 6 devices; use the simulator instead"
The compilation is correct without issues.
I changed the background of the red banner, and I moved all the views that would hide the banner, but still I couldn't see it. Inside the viewDidLoad method, I have placed it in different positions
From Google admob statistics I see that increase requests, this I don't understand. O___O
The AdMob SDK is the latest.
I appreciate any help.
My code:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_728x90.height,
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.delegate = self;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];
bannerView_.backgroundColor= [UIColor redColor];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
#"6A1E19F-xxxxx-xxxx-xxxxDF38593ECBD" ,
#"9bc75xxxxxxxxxxxxxxx762de7c79fb",
nil];
request.testing = YES;
[bannerView_ loadRequest:request];
try this
request.testDevices = [NSArray arrayWithObjects:#[#"GAD_SIMULATOR_ID"], nil];
[yourbannerview loadRequest:request];
and delete request.test, is disabled now :/

Sharing photos on facebook from iOS application without facebook app

Is it possible on iOS < 6?
In iOS 6+, I can share using message composer.
What about previous version of iOS? FB SDK share uses facebook app id so it's not the way.
Maybe i can open native facebook app with scheme like fb://share/photo/[image_data]?
Any other ideas?
For iOS < 6, you can always used ShareKit plugin.
In this repository, they share nice example to share image on your fb account.
Have a look at the class ExampleShareImage:
- (void)loadView
{
[super loadView];
self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"sanFran.jpg"]] autorelease];
imageView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height);
[self.view addSubview:imageView];
}
- (void)share
{
SHKItem *item = [SHKItem image:imageView.image title:#"San Francisco"];
/* optional examples
item.tags = [NSArray arrayWithObjects:#"bay bridge", #"architecture", #"california", nil];
//give a source rect in the coords of the view set with setRootViewController:
item.popOverSourceRect = [self.navigationController.toolbar convertRect:self.navigationController.toolbar.bounds toView:self.view];
*/
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
[SHK setRootViewController:self];
[actionSheet showFromToolbar:self.navigationController.toolbar];
}
You can also integrate FBConnect framework provide by Facebook.

Resources