Game Center(live) only showing local scores - ios

After posting my score to Game Center only local score is visible from my app as well as from the game centre application.
Weird thing is sandbox worked fine and shown score for all test accounts.
This is the part of my code where i report score:
- (void) reportScore: (int64_t) score forLeaderboardID: (NSString*) identifier
{
if (!_gameCenterFeaturesEnabled) {
NSLog(#"Player not authenticated");
return;
}
GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: identifier];
scoreReporter.value = score;
scoreReporter.context = 0;
NSArray *scores = #[scoreReporter];
[GKScore reportScores:scores withCompletionHandler:^(NSError *error) {
if (error) {
NSLog(#"Error:%#",error);
}
}];
}
Score challenges work fine and i get notified when challenge is completed.
App was released a day ago, is this usual?

I am seeing the same problem on my game that was released on 27th November. The sandbox leaderboards all worked fine. All the scores are viewable via iTunes connect.
If you look on the apple developer forums there are a few people with similar problems with apps released in the last 10 days.
I've posted a bug report via the Apple 'report a bug' system, but who knows if they even check that. I'm hoping this can get resolved quickly as it is somewhat spoiling my Christmas themed score chasing game :-(
UPDATE: My issue has been resolved as it seems has several others on the Dev Forums. I hope yours is resolved too.

Related

Game Center Challenges in iOS 10

I've implemented Game Center features like achievements and leaderboards, and now I'm working on the challenges. I was under the impression that I didn't have to add any additional code - if I had achievements or leaderboards, players would be able to send challenges to their friends. But now, in iOS10, you no longer have the ability to add players as friends - the challenges are handled through iMessages. The problem is - I don't see that feature anywhere in the GKViewController screen. If you select an achievement/leaaderboard score, you can tap on 'Challenge Friends', but it only suggests the players you already have in your friends list rather than in your contact list. Apple has also deprecated GKChallengesViewController, so I'm not sure where to look on how to do this.
Does anyone know how to add the iMessage Challenges feature to Game Center in iOS 10?
Update: I have seen that this feature lives within the GKMatchmakerViewController, but that seems to be for multiplayer type things. I'm still not sure how to use this to just send challenges.
From the Apple Docs:
Issuing a challenge does not display a user interface to the player issuing the challenge; this is code you need to implement yourself.
There are also a few examples on how to issue challenges and how to find players you can invite, such as:
- (void) challengePlayersToCompleteAchievement: (GKAchievement*) achievement
{
[achievement selectChallengeablePlayers:[GKLocalPlayer localPlayer].friends withCompletionHandler:^(NSArray *challengeablePlayerI, NSError *error) {
if (challengeablePlayers)
{
[self presentChallengeWithPreselectedPlayers: challengeablePlayers];
}
}];
}
...or:
- (void) challengeLesserMortalsForScore: (int64_t) playerScore inLeaderboard: (NSString*) leaderboard
{
GKLeaderboard *query = [[GKLeaderboard alloc] init];
query.leaderboardIdentifier = leaderboard;
query.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
query.range = NSMakeRange(1,100);
[query loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
NSPredicate *filter = [NSPredicate predicateWithFormat:#"value < %qi",playerScore];
NSArray *lesserScores = [scores filteredArrayUsingPredicate:filter];
[self presentChallengeWithPreselectedScores: lesserScores];
}];
}
By the looks of it you still can only invite players that are already part of game center, i.e. no arbitrary "contacts" from the contact list (which makes sense), but this is only an assumption.

How implement auto match of Game Center on iOS

I make the turn-based game on Game Center.
When I search another user through auto-match function, does GameCenter search another user that this game was installed or user that have free time?
Because when I implement auto match feature on turn based game, it returns null value,
I want to know more detail about the auto match feature.
If GameCenter searches the user that game was installed and the game is not famous, then I think that auto-match can't run.
How can I implement auto-match feature programmatically?
Following codes doesn't return any user of game center.
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 2;
[GKTurnBasedMatch findMatchForRequest: request withCompletionHandler:^(GKTurnBasedMatch *match, NSError *error)
{
if (match){
//[self performSegueWithIdentifier:#"GamePlayScene" sender:match];
NSLog(#"match id: %#", match.matchID);
}
}];
Because it has very little info on sites for auto-match feature, so please help me for auto-match.
Thanks for your help.

Why is there no error being reported when I send a score to a GC leaderboard that does not exist?

My Game Center game, upon authentication, for testing I am sending a score to a leaderboard that clearly does not exist in my iTunes Connect page:
// Successful authentication here
[self reportScore:1000 forLeaderboardID:#"blah blah blah blah"];
And here's the method:
-(void)reportScore:(int64_t)score forLeaderboardID:(NSString*)category {
GKScore *scoreReporter = [[GKScore alloc] initWithCategory:category];
scoreReporter.value = score;
scoreReporter.context = 0;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error == NULL) {
NSLog(#"Score sent successfully");
} else {
NSLog(#"Score submission failed: %#",[error localizedDescription]);
}
}];
}
I am getting
Score sent successfully
Why? I definitely don't have such leaderboard in my game.
Some facts:
My game is of course in iTunes Connect
Game Center seems to work in general. I can make multiplayer matches just fine.
The game has no achievements.
The game is in sandbox mode.
I am authenticated with a test user.
The game in iTunes Connect does have one leaderboard, but definitely not the one I'm referring to in the code above.
Using iOS 7 on an iPhone 5.

IOS in-app purchases stopped working suddenly, fetching null identifiers

My in-app purchases were working until yesterday and today I am submitting my app for review. The only change that I made is that in the app page in the iTunes, I connected my app (by checking) with the in-app purchases.
From that time, every time I try in my debug app to buy something with my test account, I am getting this error:
NSInvalidArgumentException', reason: 'Invalid product identifier: (null)'
I have already:
re-installed my app
logged out from my store and used again my test account
but today nothing seems to work. The exact same code was working perfect yesterday, with the same test account.
May it be because I did this change in itunes? I am worrying what would happen when my app gets approved and goes online.
Any help is greatly appreciated.
EDIT:
The problem is that the array _products stays nil.
- (void)reload {
_products = nil;
NSLog(#"reload is called");
[[VimaIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success) {
_products = products;
NSLog(#"Success from AppStore");
}
}];
for (SKProduct* product in _products) {
NSLog(#"In-app item:%#",product.localizedTitle);
}
}
The Success log message is never called. Yesterday I had no problem, with the same code.
EDIT:
after a lot of tries, it works. Without changing anything. It seems that the server takes a lot of time to respond back. However, I cannot buy the product since I get an "cannot connect to itunes". Why that might happen?
EDIT2:
In other tries, the problem seems to be in this code:
pragma mark - SKProductsRequestDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
NSLog(#"Loaded list of products...");
_productsRequest = nil;
NSArray * skProducts = response.products;
for (SKProduct * skProduct in skProducts) {
NSLog(#"Found product: %# %# %0.2f",
skProduct.productIdentifier,
skProduct.localizedTitle,
skProduct.price.floatValue);
}
_completionHandler(YES, skProducts);
_completionHandler = nil;
}
after the for loop. Especially, I get a BAD_ACCESS in line: _completionHandler(YES, skProducts);
A problem with the Xcode 5 simulator has been reported but not fixed. See this post describing the situation.
Actually the problem was that during these days the whole Apple Dev Center was down, so the above code is working for anyone else who is looking for an example.

GameCenter not updating leaderboard

Using the sandboxed Gamecenter.
No matter what I do the scores never appear in a leaderboard.
I am using the following code:
- (void)scoreReported: (NSError*) error {
NSLog(#"%#",[error localizedDescription]);
}
- (void)submitScore{
if(self.currentScore > 0)
{
NSLog(#"Score: %lli submitted to leaderboard %#", self.currentScore, self.currentLeaderBoard);
[gameCenterManager reportScore: self.currentScore forCategory: self.currentLeaderBoard];
}
}
And scoreReported doesnt produce an error, yet the score doesnt appear in the leaderboard. I know the category is correct as I use currentLeaderBoard in:
- (void)showLeaderboard {
NSLog(#"leaderboard = %#", self.currentLeaderBoard);
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != NULL)
{
leaderboardController.category = self.currentLeaderBoard;
//leaderboardController.category = nil;
leaderboardController.timeScope = GKLeaderboardTimeScopeWeek;
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController: leaderboardController animated: YES];
}
}
I have tried the usual
2 different sandbox GC accounts to get the leaderboard working
Even tried 4 different GC accounts each logging in on both the simulator (iOS 6.1) and device (iOS 6.0.1)
Yet still no joy
any suggestions - or is it just that the sandboxed gamecenter is far too buggy!!! (I would raise a bug about sandbox but the apple bug reporting form has a bug in it so that doesnt work either)
Score reporting to Game Center works almost immediately for me, even in sandbox mode.
Here are the few things you can try
Make sure the the Leaderboard identifiers are correct when reporting scores (Should exactly match with "Leaderboard ID"s in iTunesConnect)
Try Deleting the test data under "Manage Game Center" section of iTunesConnect
Delete the application, launch "Game Center" application in your device and goto "Games" tab and remove your app. Reinstall the app and try reporting the score again.
Make sure [gkScore reportScoreWithCompletionHandler:^(NSError *error) doesn't return any error
For those who want to know this what I changed my submitScore method to:
- (void)submitScore {
GKScore * GCscore = [[GKScore alloc] initWithCategory:self.currentLeaderBoard];
GCscore.value = [[NSUserDefaults standardUserDefaults] integerForKey:#"NEWSCORE"];
[GCscore reportScoreWithCompletionHandler:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (error == NULL) {
NSLog(#"Score Sent");
} else {
NSLog(#"Score Failed, %#",[error localizedDescription]);
}
});
}];
}
and it worked

Resources