customize an action of iphone home button to submit score in gamecenter
i have a button in my app a button that submit score to gamecenter and works. this is the code:
now i'd like to submit score before app is closed with home button. i thought to customize an action of home button (if it is possible) or perhaps i make the same line of code in viewDidUload...or something like that... will i be sure that that action will be performed before unloading the app? i should make that code in dealloc method? thanks
Code:
-(void)subScore{
GKScore *scoreRepoter = [[[GKScore alloc] initWithCategory:@"123456"] autorelease];
scoreRepoter.value=100;
[scoreRepoter reportScoreWithCompletionHandler:^(NSError *error) {
if (error!=nil) {
NSLog(@"errr submitting");
}else
NSLog(@"ok!");
}];now i'd like to submit score before app is closed with home button. i thought to customize an action of home button (if it is possible) or perhaps i make the same line of code in viewDidUload...or something like that... will i be sure that that action will be performed before unloading the app? i should make that code in dealloc method? thanks
If you need to do stuff when your app deactivates use your UIApplicationDelegate's applicationWillResignActive method (and accept all caveats within).
But, you really should submit scores automatically and immediately after the game is over. People are likely to view the leaderboards right after a game ends, and if you submit when they hit the leaderboard button it's already too late.
But, you really should submit scores automatically and immediately after the game is over. People are likely to view the leaderboards right after a game ends, and if you submit when they hit the leaderboard button it's already too late.
thanks for the answer.
my game ends when the home button is clicked so i had to use applicationWillResignActive, but what does "(and accept all caveats within)." mean?
the app will show popup or something like?
can i submit while the app is starting?
thanks
my game ends when the home button is clicked so i had to use applicationWillResignActive, but what does "(and accept all caveats within)." mean?
the app will show popup or something like?
can i submit while the app is starting?
thanks
The home button is not supposed to end anything... the app's supposed to pick up right where it left off when it's reopened.
(Nov 28, 2011 06:13 AM)sefiroths Wrote: what does "(and accept all caveats within)." mean?
It means applicationWillResignActive only gives you a few seconds to save state and clean up, and network access might be cut off before you get a chance to send anything. That's why you really should send scores as soon as the player hits your game over screen.
It sounds like you might be jumping into this without a real understanding of how iOS works. I hate to say "RTFM" but if you're just starting out you really should (at least) read the Programming Guide: http://developer.apple.com/library/ios/#...ction.html
i'm a beginner.
i have readed all manuals, ton of documentation.
i remember a part, sometimes i have it not really clear, sometimes i forgot.
i thought that the best way to remember and learn is to read all documentation, (or what i need at the moment), then try to put in practise.
i ask only if i don't remember and don't find the documentation relatively to what i'm doing
thanks for all the helpful and kind answers
i have readed all manuals, ton of documentation.
i remember a part, sometimes i have it not really clear, sometimes i forgot.
i thought that the best way to remember and learn is to read all documentation, (or what i need at the moment), then try to put in practise.
i ask only if i don't remember and don't find the documentation relatively to what i'm doing
thanks for all the helpful and kind answers
I think you should try actually using a device before you try to design software for it!
ok thanks for the tip!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| gamecenter hidden achievement is visible | sefiroths | 0 | 920 |
Nov 7, 2012 12:20 PM Last Post: sefiroths |
|
| customize uialertview | sefiroths | 1 | 2,666 |
Aug 10, 2012 02:02 AM Last Post: sefiroths |
|
| skinning gamecenter UI | sefiroths | 6 | 8,991 |
Aug 17, 2011 10:09 AM Last Post: sefiroths |
|
| glutBitmapChar and my score. | mikey | 2 | 2,345 |
May 15, 2009 10:08 AM Last Post: mikey |
|
| Left mouse button causes moueup event despite button still being pressed. | QuestingCordiial | 28 | 10,163 |
Jun 21, 2008 03:18 PM Last Post: AnotherJake |
|

