Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 303

Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
12/13/13 06:35 PM (11 years ago)

Game Center with iOS 7?

Has anybody gotten game center working with iOS 7? I can get it to compile, but the pop-up screen never appears anymore when the app launches. It's pretty crazy how Apple never thinks to update their sample code. The GKTapper sample is the same one from 4 years ago and I has all kinds of errors now that BT 3.0 is using arc
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
12/13/13 06:41 PM (11 years ago)
I think this is the book i used to set up game center in the NAD advanced quiz plugin. I havn't tested it with ios 7 yet. But I found gamecenter really simple to set up. Its in the last chapter about gamekit. http://www.amazon.com/iOS-Recipes-Problem-Solution-Hans-Eric-Gr%C3%B6nlund/dp/1430245999/
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
12/13/13 09:49 PM (11 years ago)
Check RayWenderlich.com You may have to buy his iOS 7 book -- a worthy purchase! - Niraj
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
12/16/13 03:25 PM (11 years ago)
thanks guys - I finally managed to find a stack overflow post that solved it for me. I linked to the working iOS 7 code in this thread - http://www.buzztouch.com/forum/thread.php?fid=6F54B0D255A4AF70998EBDF&tid=6F54B0D255A4AF70998EBDF
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/02/14 02:36 PM (11 years ago)
I can't seem to get my gamecenter to load. no errors, but not sure if i've added it correctly to the view controller. i noticed that there were two viewdidload methods so i added the gamecenter code to that block of code however, the gamecenter doesnt popup anymore when the app is launched nor does it show up in the gamecenter game list here is my code, @absentia can you match it up with your code, just in case there is a difference? Thanks! //viewDidLoad... -(void)viewDidLoad{ [BT_debugger showIt:self theMessage:@"viewDidLoad (super)"]; [super viewDidLoad]; self.currentLeaderBoard = kLeaderboardID; self.currentScore = 0; if ([GameCenterManager isGameCenterAvailable]) { [self.gameCenterManager setDelegate:self]; [self.gameCenterManager authenticateLocalUser]; } else { // The current device does not support Game Center. } //adjust view edges on iOS7, depending on the navBar transparency... if([self respondsToSelector:@selector(edgesForExtendedLayout)]){ if(![[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"navBarStyle" defaultValue:@""] isEqualToString:@"transparent"]){ self.edgesForExtendedLayout = UIRectEdgeNone; } } } - (IBAction) showLeaderboard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentViewController: leaderboardController animated: YES completion:nil]; } } - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissViewControllerAnimated: YES completion:nil]; } - (IBAction) showAchievements { GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init]; if (achievements != NULL) { achievements.achievementDelegate = self; [self presentViewController: achievements animated: YES completion: nil]; } } - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController; { [self dismissViewControllerAnimated: YES completion:nil]; } //GameCenter View Did Unload - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.gameCenterManager = nil; self.currentLeaderBoard = nil; self.currentScoreLabel = nil; }
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/02/14 03:07 PM (11 years ago)
The code I use is slightly different..I call authenticateLocalUser in viewController.m with after a three second delay. Otherwise it seems to load behind the view. Try replacing all of your code with this - //GameCenter View Did Load - (void)viewDidLoad { [super viewDidLoad]; //adjust view edges on iOS7, depending on the navBar transparency... if([self respondsToSelector:@selector(edgesForExtendedLayout)]){ if(![[BT_strings getStyleValueForScreen:self.screenData nameOfProperty:@"navBarStyle" defaultValue:@""] isEqualToString:@"transparent"]){ self.edgesForExtendedLayout = UIRectEdgeNone; } } self.currentScore = 0; if ([GameCenterManager isGameCenterAvailable]) { self.gameCenterManager = [[GameCenterManager alloc] init]; [self.gameCenterManager setDelegate:self]; [self performSelector:@selector(authenticateLocalUser) withObject:nil afterDelay:3]; } else { // The current device does not support Game Center. } } - (IBAction) showLeaderboard { GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.category = self.currentLeaderBoard; leaderboardController.timeScope = GKLeaderboardTimeScopeWeek; leaderboardController.leaderboardDelegate = self; [self presentViewController: leaderboardController animated: YES completion:Nil]; } } - (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController { [self dismissViewControllerAnimated: YES completion:nil]; } - (IBAction) showAchievements { GKAchievementViewController *achievements = [[GKAchievementViewController alloc] init]; if (achievements != NULL) { achievements.achievementDelegate = self; [self presentViewController: achievements animated: YES completion:Nil]; } } - (void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController; { [self dismissViewControllerAnimated: YES completion:nil]; } -(void)authenticateLocalUser { __weak GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) { if(viewController) { [[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:viewController animated:YES completion:nil]; } else if(localPlayer.isAuthenticated == YES) { NSLog(@"already authenticated"); } else { NSLog(@"game center disabled"); } }; }
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/02/14 03:14 PM (11 years ago)
ah ok. great thanks. i did notice later that the code worked but it didn't load. your code worked beautifully! Thanks
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.