Xcode - Admob banner setting with targeting and test devices - ios

I am working on my iOS app and trying to place a banner on the bottom of the page.
First of all, I set a BOOL (BannerAd) which is initially "NO" and set to "YES" when user hits the "Submit" button. By doing this tried to avoid requesting ads eveytime the user hit "Submit". This seems to work but world be nice if you can comment on it.
My interface has a "Datepicker" where the user selects his/her Birthday. I wanted to use this information for ad targeting. Also I know my application will be used in "Germany" so I set the location manually to "Germany" since my app doesn't request location information from user. And finally I am trying to test my app on my device where I set my test device UDID in "testDevices"
My problem is, I think my requests don't work. When I enter my own "adUnitId", I get paid ads on my device (which may cause a problem). Also when I tried to change the location, for example to "France", I still get local ads. I guess my location is not working and AdMob is using the network to determine the location. Which makes me think my "Birthday" information isn't working, too.
Below is the code I use and I don't know which part is wrong. I did researched and did everything according to the guides. I am not experienced and hoped that you guys can help me out!
Appreciated!
// Show Banner Ad
if (BannerAd == NO)
{
self.bannerView.adUnitID = #"ca-app-pub-3940256099942544/2934735716"; // TEST ID
self.bannerView.rootViewController = self;
NSDate *birthday =[datepick date];
GADRequest *request = [GADRequest request];
[request setBirthday: birthday];
[request setLocationWithDescription:#"Germany"];
request.testDevices = #[ #"b23cbd41317324cd9afd14dc848f2f0e" // TEST DEVICE
];
[self.bannerView loadRequest:[GADRequest request]];
BannerAd = YES;}

I can't understand your question(s) so good. Sorry.
If you want to put your adMob banner on the bottom of the screen, just use:
bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0,self.view.frame.size.height - 50, self.view.frame.size.width, CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height)];

Related

Spotify SPTAuthViewController issues

I am having trouble authorizing Spotify. The first time I believe I logged in but it froze up on the last page of the authentication process. Now when I try to log in, the popover is a blank screen. Also when I clear my cookies, the login screen appears but won't proceed past me entering my username and password. I appreciate the help here
I have tried doing this in both objective c as per the "Simple Track Playback" demo in the sdk and in swift using this tutorial http://pachulski.me/2015/spotifyframework-with-swift/
I was running into the same issue (blank popover). This was fixed when I added "App Transport Security Settings" (type: Dictionary) into the info.plist, and then implementing "Allow Arbitrary Loads" (Type: BOOL) and setting it to "YES".
Please refer to the screenshot:
EDIT: Added code to answer Brian's question in comments:
- (IBAction)loginButtonPressed:(id)sender {
_authVC = [SPTAuthViewController authenticationViewController];
_authVC.delegate = self;
_authVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
_authVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
self.definesPresentationContext = YES;
[self presentViewController:_authVC animated:NO completion:nil];
}

<Google> Must specify extras for registerAdNetworkExtras:?

I'm receiving a message in Xcode's debug area stating :
Must specify extras for registerAdNetworkExtras:
I didn't get this error yesterday but today I'm getting it on debug area out of nowhere. I didn't change my code in any way. Is this an error on google's end? Why am I receiving this message?
My code to get AdMob banner:
adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
adMobView.adUnitID = #"unit-id";
adMobView.rootViewController = self;
GADRequest *request =[GADRequest request];
request.testDevices = #[ #"testdeviceID" ];
[adMobView loadRequest:request];
Here i found the right answer, is a last version SDK issue, that don't have effect on the mediation/ad serving functionality. Hope this help.
More info: Ram Parameswaran (Mobile SDK Team) say: "This issue does not affect functionality and can be ignored for the time being. Changes will be made to address the issue and pushed out in a future release."

iOS: Sign In with Google button

I am new to iOS development and working on a project where I want my users to login with Google.
I worked my way through Google's documentation, and could login in as well. All now I wanted was button/image which says "Sign in with Google" as
I looked through Google's SDK, but there is no exact image like that. so I tried to create my own which looks like
where ImageView is replaced with image in Google'e SDK.
Problem
When I run this, this doesn't look like it should
The red color of image and button do not match, neither I see vertical black line.
Question
a.) Where can I find the "Sign in with Google" button for iOS?
b.) The downloaded png might not work since as per the device we need two different resolutions #1x and #2x
Please let me know how can I get it?
UPDATE
- The problem was that the GooglePlus.bundle was not correctly loaded in my project. After fixing it, I see a button, but no text like
Has anyone seen this before?
You don't need an image that looks like this, just use the following code instead of that button and this will create a button as well as its action which will perform Google+ SSO for you.
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
//signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email
// You previously set kClientId in the "Initialize the Google+ client" step
signIn.clientID = kClientId;
// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = #[ kGTLAuthScopePlusLogin ]; // "https://www.googleapis.com/auth/plus.login" scope
//signIn.scopes = #[ #"profile" ]; // "profile" scope
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;
Just add the signIn button to your view and it should work. Here is the link in case you need any help
https://developers.google.com/+/mobile/ios/sign-in

ios can players form teams of 2 and play other teams of 2 in game center [duplicate]

I have a "Play Now" button in my app that allows players to be auto-matched with other random players. Maybe I'm missing this somewhere in the docs, but how do I write the code to auto match players?
The Game Center sandbox server has been messed up the last few days, so I'm having a hard time trying different things since I have to guess because the Game Kit docs aren't exactly clear on how to do this. Currently, I have code setup (but untested) to create a match with a friend...
NSArray *playerList = [NSArray arrayWithObject:pid];
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 4;
request.playersToInvite = playerList;
[[self waitingIndicator] startAnimating];
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
if (error)
{
//handle error
}
else if (match != nil)
{
self.myMatch = match;
//start match code
}
}];
But how do I auto match two random people looking for a game? My guess, since the docs don't say it, or I'm missing it, is that in order to create an auto match, I simply set the playersToInvite property of the match object to nil? If not, how do I create an auto match?
One other question, while we're on the topic, the Game Kit docs site a few common matchmaking scenarios, one of them being...
A player can also create a network
match using the Game Center
application. When they invite a friend
into a multiplayer game, your
application is launched on both
devices, and each copy of your
application receives an invitation to
join the game.
But I can't figure out how to do this in the Game Center app for testing purposes. How does a user create a network match using the Game Center app? I don't see any buttons for that anywhere in the Game Center app.
Thanks in advance for your wisdom!
Ok, now that the sandbox Game Center server is back up, I was able to confirm that auto-matching works by setting the playersToInvite property to nil, or not setting it all.

ShareKit 2.0 facebook share URL

I have the following code for sharing with facebook using ShareKit:
-(void)buttonAction:(id)sender
{
[SHK setRootViewController:self];
SHKItem *facebookItem = [[SHKItem alloc] init];
facebookItem = [SHKItem URL:[NSURL URLWithString:#"www.google.com"] title:#"Some test title"];
facebookItem.facebookURLSharePictureURI = #"www.myTestPicture.com";
facebookItem.facebookURLShareDescription = #"Custom share description";
[SHKFacebook shareItem:facebookItem];
}
Everything works fine except for one scenario. My application has a log out button. Upon hitting this button, all the data save in NSUserDefaults gets erased. So, I log in and then make a post to facebook. Then, I log out (erase all the data) and afterwards log back in with facebook. Everything works so far. However if I try to make another post to facebook at this point, my application crashes with no error showing up in the console. If I restart the application and try to make the same post again, it works. It only crashed after loging out, back in (with facebook) and then trying to make the post. Any clues? Thanks.
EDIT: Seems like it is crashing in FBDialog at line 341:
_webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];
Ok, so after some digging aroung here, it seems to be Apple's bug in iOS 5.1 according to Why does clearing NSUserDefaults cause EXC_CRASH later when creating a UIWebView?

Resources