Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 34    Views: 170

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

updated game center code for iOS 7

Hey guys, some of you may have noticed that Apple's old GKTapper download has a ton of errors now, and I'm pretty sure it doesn't work at all with iOS 7 and the BT 3.0 core. I finally got it cleaned up and error free Here are the updated GameCenterManager.h and .m files if anybody is interested - https://www.dropbox.com/sh/a03l0wm5wkjpo5z/M4E5ToboPA
 
MacApple
Apple Fan
Profile
Posts: 4675
Reg: Oct 25, 2010
USA
61,150
like
12/16/13 03:28 PM (11 years ago)
Rock star!
 
EdReyes
Lost but trying
Profile
Posts: 574
Reg: Oct 21, 2013
location unknow...
17,640
like
12/16/13 03:31 PM (11 years ago)
Thanks for the fix
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
12/16/13 05:43 PM (11 years ago)
Kitchen Arrigato! Cheers! -- Smug
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
12/16/13 05:46 PM (11 years ago)
Look it at you Mr. Mr.! Something to be said for Dark Days Of Alaska in The Winter....better coding environment! Thank you kind sir :)
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
05/15/14 08:41 AM (11 years ago)
@Absentia, would you still have that code handy by any chance? I am having a go at setting up Game Center (with a lot of huffing and puffing) Did you get to run it smoothly in the end? Cheers, Farcat
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
05/15/14 12:54 PM (11 years ago)
Sure, here you go - https://www.dropbox.com/sh/n4skb51frnmsbre/AAC2Qr-nBjFcXx-1TMLycyINa It's working perfect for me - let me know if you have any problems
 
farcat
buzztouch Evangelist
Profile
Posts: 1008
Reg: Jan 27, 2012
France
13,230
like
05/15/14 01:09 PM (11 years ago)
Thanks a million!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/15/14 08:51 AM (11 years ago)
Just spotted this thread as I am trying to integrate game centre into the std buzztouch quiz. @Absentia, your code stopped my compile errors and many thanks for that. I'm now finding the howto https://www.buzztouch.com/files/howtos/Game-Center-Tutorial.pdf for quiz gamecentre integration seems to be out of date and I have ground to a halt with errors after page 6. I was just wondering if anyone has had this working this for Buzztouch 3.0/ios 7? Alan
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/15/14 10:06 AM (11 years ago)
+++++1 to what AlanMac said. I've accessed Abzebtia's new files on dropbox, but I would LOVE to see a new PDF made for how to do this. Anybody???
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/15/14 01:45 PM (11 years ago)
Step 5 is really the main part of the PDF that needs to be updated - I think it was Buzztouch's switch to automatic reference counting that made a lot of the original code start going haywire. Try replacing all of the code from step 5 (after the @synthesize statements) with the following. //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.7]; } 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"); } }; } //The above code should be between the @synthesize statements and the initWithScreenData method
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/15/14 01:54 PM (11 years ago)
Fantastic - thanks @Absentia, I'll try that in the morning. Cheers, Alan
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/15/14 02:19 PM (11 years ago)
Wicked awesome - thank you!!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/16/14 04:42 AM (11 years ago)
I've tried the code @Absentia many thanks, it dropped in OK, but there is some other part of the puzzle that I have not on top of. Any extra help is really welcomed, we could end up with a BT 3.0 updated howto out of this. 1) There are two main problems - one is a couple of errors that I cannot make go away (see the bottom of this post) 2) Not sure where to add the submit button in step 8. Overall, I went through the published howto pdf for a BT 1.5 app. I made some notes, there are certainly a couple of things to change as the Buzztouch 3.0 quiz code is not the same as it was in BT 1.5. Here are my notes: Step 1 - The Apple site has changed a bit, but the directions are broadly the same. Step 2, I would suggest that with the changes, it would be better for somebody to create a modified AppSecificValues.h file to @Absentia'sGameCenterManager.h and .m files and not mention downloading from Apple but use that instead. In step 3, substitute @Absentia GameCentreManager .h and .m files for the Apple code, use the downloaded GK Tapper AppSpecificValues.h file as described. I skipped the rest of step 3, it doesn't seem to apply in Xcode 5, although I could be wrong here? In Step 4, in the BT_viewController.h file, I found the guide confusing because the screen-grab did not match the text. I went with the code in the text, I commented out the original statement and then added the extra code as described and ended up with the following: /* following commented out for Game Center integraton mod @interface BT_viewController : UIViewController <UIAlertViewDelegate, ADBannerViewDelegate, MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate>{ } */ // mod - the following replaces the above commented out for Game Center integraton @interface BT_loadConfigDataViewController : UIViewController <UIAlertViewDelegate, ADBannerViewDelegate, UIActionSheetDelegate, GKLeaderboardViewControllerDelegate, GKAchievementViewControllerDelegate, GameCenterManagerDelegate>{ GameCenterManager *gameCenterManager; int64_t currentScore; NSString* currentLeaderBoard; IBOutlet UILabel *currentScoreLabel; BT_item *screenData; UIView *progressView; } // the above Game Centre integration mod ends here In Step 5, looking at BT_viewController.m, add the import and synthesize statements as described. On step 5, in BT_viewController.m, I added the import statements as described. Beware of cutting and pasting from the PDF, I had syntax errors that disappeared when re-typed manually. Added the synthesize statements. Next on step 5, I added the @Absentia code beneath the @sysnthesize statements, there was no code to delete and No errors. In step 6, the localizable strings file is now in folder en.lproj Step 7, no change to the instructions, all good. Step 8, looking at BT_screen_quiz.m there were errors starting at line 92 - beware of cutting and pasting from the pdf, typing it manually was OK. Where the instructions say "Delete the section between //show scoreboard and //show quiz reward screen", there is no longer a show scoreboard to find. Code added above //show quiz reward screen as described OK. Where it says to look for //scoreboard button shows if we have it this is not there now, so do not know where to add the "submit Score Button" code. This will be significant. Step 9 is straightforward and unchanged. Cannot execute step 10 as I have two errors. One is in file appdelegate.h Parse Issue - expected a type, set against line 107 -(BT_viewController *)getViewController; One is in file BT_application.h against line 75 -(BT_viewController *)getViewControllerForScreen:(BT_item *)theScreenData;
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/18/14 01:37 PM (11 years ago)
Hi @Absentia, I'm not sure where I went wrong, do you have any ideas please? Cheers, Alan
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/18/14 02:18 PM (11 years ago)
Ok, I'm realizing there is a lot more outdated code in that tutorial than I initially thought. It was so long ago, but now I remember that I completely reworked step 8 as well. I would suggest completely ignoring step 8 completely and doing the following instead - 1. in BT_screen_quiz.h, add "GKGameCenterControllerDelegate" to the @interface line of code ---- screenshot example with highlighted code - https://www.dropbox.com/s/at7s9zx8lelupdp/Screen%20Shot%202014-08-18%20at%2012.59.40%20PM.png?dl=0 also, add "-(void)showScores;" to the list of method declarations 2. in BT_screen_quiz.m, in the "quizEnded" method, paste the following code (on a side note, you might notice that I have this set up to get the leaderboard name from the nickname of the quiz screen - so if you are using this code, your quiz screen nickname needs to always match your game center leaderboard id in iTunes Connect) - if(totalPoints > 0) { self.currentLeaderBoard = [self.screenData itemNickname]; [self.gameCenterManager reportScore: totalPoints forCategory: self.currentLeaderBoard]; } screenshot example with highlighted code - https://www.dropbox.com/s/xpwh1eht37gm6cd/Screen%20Shot%202014-08-18%20at%2012.54.08%20PM.png?dl=0 3. And finally for the code to show the scoreboards you should add the following two methods - -(void)showScores{ GKGameCenterViewController* gameCenterController = [[GKGameCenterViewController alloc] init]; if (gameCenterController != nil) { self.currentLeaderBoard = [self.screenData itemNickname]; gameCenterController.leaderboardCategory = self.currentLeaderBoard; gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards; gameCenterController.gameCenterDelegate = self; [self presentViewController:gameCenterController animated:YES completion:nil]; } } - (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)gameCenterViewController { [self dismissViewControllerAnimated:YES completion:^{ gameCenterViewController.gameCenterDelegate = nil; }]; } 4. The one part of step 8 which should still work is the final part in which you use the following code to add the button to the action sheet - //Submit Score Button [finishedButtons addObject:NSLocalizedString(@”quizSubmitScore”, @”Submit Score”)]; let me know how it works out
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/18/14 02:23 PM (11 years ago)
Dang - this is getting more confusing....
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/18/14 02:54 PM (11 years ago)
Thanks @Absentia, there is hope! I'll give this a go in the morning. Cheers, Alan
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/18/14 03:01 PM (11 years ago)
All right Alan - I'm crossing my fingers for you, and hoping for a recap of ALL the steps to get this to work. Maybe based on all your efforts, we can update that Game Center PDF on the main page???
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/19/14 10:37 AM (11 years ago)
Thanks @Abesentia, I managed to drop all the code in. I had a bundle of syntax errors, all of which were related to curring and pasting quote marks ( " ) from the original howto - note to self - never cut and paste from PDF's. So I got to the point where the app will compile and run, but I now can see that I have not set up the game centre integration correctly. When my app launched, I was invited to log in, but there was no matching app in the game center. Could be one of many things, but I took a baby step today and I'm going to stop for the day while I am ahead. My eyes are going square... I would like to say a big thanks @Absentia, as I would never have managed to get this far without your help. Hopefully I will make another step tomorrow!
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/19/14 01:47 PM (11 years ago)
Any tips for me on where to start, other than what is here already?
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/19/14 02:21 PM (11 years ago)
Hi Mike, just jump in with both feet! I think setting up the Apple Game Center side of things could do with a closer look. One tip, which I should have followed myself, is to run the app after every edit, so if you break something, you'll know where and when. Cheers, Alan
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 10:23 AM (11 years ago)
OK, I have managed to get my quiz app to run and when the quiz finishes I am invited to submit my score, which is good. But, when it gets to the next screen, I am seeing an error message 'No Leaderboard'. I've worked out you set the value for the leaderboard in AppSpecificValues.h and I've followed the naming convention "com.appname" throughout to get this far. I have deleted and re-created the leaderboard in itunesconnect, but that didn't help. I feel I am close, not sure what else to try?. Any suggestions please? Alan
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/21/14 10:39 AM (11 years ago)
Which quiz plugin are you using?
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 11:04 AM (11 years ago)
the free one!
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/21/14 11:11 AM (11 years ago)
Oh man! You totally should try advanced quiz! For $14.99, your scoreboard and reward issue will be removed! The plugin has a feature to put in the scoreboard within the plugin. Very easy! You would dig it. I'm a purchaser of the plugin, not the developer. Well worth it if you want to do a quiz, no brainer if you want to do more than one
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 11:43 AM (11 years ago)
You are probably right Mike. If I had realised it had a scoreboard then I would have done that in the first place! On the positive side, I am pretty close and I think the issue I have now may be an Apple one. Alan
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/21/14 11:47 AM (11 years ago)
Sweet!!!! You are blazing a trail for me!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 01:02 PM (11 years ago)
Thanks Mike, but if you use the advanced quiz plugin, why you would want or need to modify the standard one?
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/21/14 01:10 PM (11 years ago)
No need to modify it at all. I just need to figure out what I'm doing wrong on game center!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 02:20 PM (11 years ago)
What bit is causing you issues Mike?
 
Mike the App Guy
Lost but trying
Profile
Posts: 435
Reg: Sep 19, 2011
Birmingham, Ala...
5,900
like
08/21/14 02:27 PM (11 years ago)
Well, I am using the old PDF and the new info, not sure what to do on which step and which info to use
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/21/14 02:52 PM (11 years ago)
Now that I have read up a little on the advanced quiz, I realise that little of this thread applies to that plugin. The bit that isn't covered is the Apple process for generating certificates and provisioning profiles to make game center work, which would be common to both plugins.
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
08/21/14 05:23 PM (11 years ago)
I do absolutely nothing in appSpecificValues.h - I noticed a while ago that that step seems to make no difference...probably because of the way I have the code set up like I mentioned above. If you use the code I posted, make sure your quiz screen nickname is identical to your leaderboard id. Second, make sure that Game Center is set to "enabled" under both your app details and your Game Center settings Finally, make sure that you have a provisioning profile selected when you are running the app @AlanMac - in response to the above post..nothing specifically needs to be done with provisioning profiles to make game center work. It is automatically selected to be an included feature every time you create a new app
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
08/22/14 01:09 AM (11 years ago)
Aaahhhh, thanks @Absentia, you actually said that earlier in the post, I just didn't understand it properly. I had a provisioning profile set up and game center was enabled. I just added a leaderboard with exactly the same as the screen nickname, I now have a message that says no leaderboard, but 2nd time around, I got a score recorded - whooohoooo! I had incorrectly focussed on the variable kLeaderBoardID - effectively that means that appSpecificValues.h has no purpose - I could probably leave it out altogether. I'm going to go back through this post and write up what worked. Cheers, Alan
 

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.