65523

Reporting score to GameCenter in iOS 9 (xCode 7.1.1)

Question:

So I have a finished game, which I'm just tidying up before submitting to the App Store.

Since I finished the majority of the coding, I've updated xCode to 7.1.1 and my device to iOS 9.1 from 8.1.

The first thing I've learnt is there's no Sandbox toggle in Game Center (which is what I've mostly always used with no problems)

Now, when I run the application, when it comes to reporting a score using this code:

-(void)reportScore{ GKScore *this_score = [[GKScore alloc] initWithLeaderboardIdentifier:_leaderboardIdentifier]; this_score.value = gameScore; [GKScore reportScores:@[this_score] withCompletionHandler:^(NSError *error) { if (error != nil) { NSLog(@"%@", [error localizedDescription]); } }]; NSLog(@"Reported to Game Center..."); }

I get this error printed to the console:

*** Terminating app due to uncaught exception 'GKInvalidArgumentException', reason: 'A GKScore must specify a leaderboard.' *** First throw call stack: (0x184e60f48 0x199a13f80... ...0x1000d9748... ...0x19a2628b8) libc++abi.dylib: terminating with uncaught exception of type NSException

which states, a GKScore must specify a leaderboard...

I'm confused, because up until I updated to iOS 9, this worked fine.

I've been reading a bunch about the merging of sandbox in iOS 9, but I don't understand all of it.

From what I can gather, it's merged into real-life accounts, all sandbox data is deleted and testing is done on real leaderboards? I may be wrong. Like I said, I'm not 100% about this.

How can I solve this problem? I'm not sure of the correct terminology to find accurate resources... I've just been wildly googling for ages.

Maybe I need to specify my LeaderboardIdentifier locally?

Thanks in advance.

<strong>UPDATE</strong>

This is even worse than I thought... All my apps that are in the App Store now crash when trying to open/submit to Game Center...?

I only just thought to test them since <a href="http://www.cultofmac.com/390755/beware-this-fix-for-nasty-ios-9-game-center-bug/" rel="nofollow">reading this</a>...

Is there a cleaner or more updated method of implementing Game Center?

Answer1:

So, I have a work around... that appears to be working. I will update accordingly over the next few hours (or days)...

My hunch was right, and if I specify the LeaderboardIdentifier using a string inside the method, it now looks like this:

//GKScore *this_score = [[GKScore alloc] initWithLeaderboardIdentifier:_leaderboardIdentifier]; GKScore *this_score = [[GKScore alloc] initWithLeaderboardIdentifier:@"myGameLeaderboardID"];

And with the handy NSLogs I also included, my call & method looks like this:

-(void) GameOver { . . . if(_gameCenterEnabled){ NSLog(@"--Reporting Score to Game Center..."); [self reportScore]; } } -(void)reportScore{ NSLog(@"--- Got to the method"); GKScore *this_score = [[GKScore alloc] initWithLeaderboardIdentifier:@"Enemies_Located"]; NSLog(@"---- Alloc GKScore done"); this_score.value = gameScore; NSLog(@"----- Score assigned to GKScore"); [GKScore reportScores:@[this_score] withCompletionHandler:^(NSError *error) { if (error != nil) { NSLog(@"%@", [error localizedDescription]); } }]; NSLog(@"Reported to Game Center..."); }

Which results in the following console print out:

2015-12-07 23:20:24.666 myGame[88.....48] Some InGame Ref: 15 2015-12-07 23:20:24.704 myGame[88.....48] --Reporting Score to Game Center... 2015-12-07 23:20:24.704 myGame[88.....48] --- Got to the method 2015-12-07 23:20:24.705 myGame[88.....48] ---- Alloc GKScore done 2015-12-07 23:20:24.705 myGame[88.....48] ----- Score assigned to GKScore 2015-12-07 23:20:24.705 myGame[88.....48] Reported to Game Center...

This is by no means an official way to fix this issue, which looking around forums a lot of people are now having, hence why I'm leaving this question unanswered for a few days... but it seems to be working for me. Please let me know if you have any luck with this too, or you know of a better way to implement this for iOS 9.

Mean while, I should probably update all my apps now -_-

Recommend

  • Ajax Routing Calling Controller Name Twice
  • Apply jquery fancybox to elements loaded via ajax
  • Returning a Min() and another field? [duplicate]
  • Rails: Calling .limit(5) changes order of results
  • How to push configuration values from Asp.Net Core MVC 2.0 config file to React TypeScript client sc
  • How to test method Jsoup.connect (static) using PowerMock?
  • Maven - which projects or techologies you are using it for?
  • SQL Table / Sub-Query Alias Conventions
  • How to launch app in landscape? (frustrated)
  • Print list item that throws error in for loop, and continue with next list item
  • Certificate error when configuring HttpClientFactory
  • show div after process register, woocommerce
  • dotnet core Method 'ValidateOptions' … does not have an implementation
  • Braintree Dropin UI does not work with Ionic Framework unless force refresh
  • android to show alert dialog from non-UI or Non activity class
  • Exception seems to be thrown repeatedly when debugging
  • How to update data into a file in a particular position in js
  • How to Moq this view?
  • how to connect to a mysql database through eclipse
  • Bootstrap navbar stays expanded on route change
  • Update a record where _id = :id with Mongoose
  • Easy way to convert a Bitmap and Png Image to text and vice versa
  • Convert C# statements including NSubstitute code to VB.net
  • Generic classes with Collection getter of other types
  • Ionic storage “get” returns null only on the second call within method
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • VBA Excel, loop through variables
  • Cloud Code function running twice
  • Clear fused location provider's location for testing
  • Trying to get the char code of ENTER key
  • Using Sax parsing to edit and write XML in VB6
  • Thread safety of a fluent like class using clone() and non final fields
  • Debug.DrawLine not showing in the GameView
  • Converting a WriteableBitmap image ToArray in UWP
  • Yii2: Config params vs. const/define
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • javascript inside java/jsp code
  • Android Studio and gradle
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can i traverse a binary tree from right to left in java?