Game Center Leaderboard score upload failed in iOS 7.0 - ios7

I've much googling because I've issue in implementing Game Center Leaderboard in iOS 7.. So I've got one important thing that is likely for solving the issue. From iOS 7.0, we should use identifier instead of category because category is deprecated from iOS 7.0.. I could get this fact from here. https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/GameKit_Guide/LeaderBoards/LeaderBoards.html#//apple_ref/doc/uid/TP40008304-CH6-SW13
So I used identifier ... but it still faces with same issue... Score upload fails..
Belows are my code for reporting score.
GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: identifier];
scoreReporter.value = score;
scoreReporter.context = 0;
scoreReporter.shouldSetDefaultLeaderboard = YES;
NSArray *scores = #[scoreReporter];
[GKScore reportScores:scores withCompletionHandler:^(NSError *error) {
//Do something interesting here.
[self callDelegateOnMainThread: #selector(scoreReported:) withArg: NULL error: error];
}];
When reports score, it shows error and error is "The requested operations could not be completed because one or more parameters are invalid."
Any solution for it? I've been almost devoting 2 days for it but not getting anything funny.. Could anyone give me a solution? Need any helps .. Thanks..

I solved my issue by removing the line
scoreReporter.shouldSetDefaultLeaderboard = YES;
:) Hope this helps other developers who are facing with the same issue as I was...

Related

Facebook Invite VC displaying weird

I am having a problem using the new Facebook SDK invite system. The view controller which appears when using FBSDKAppInviteDialog displays very oddly, then disappears before the user has time to interact with it.
FBSDKAppInviteContent *content =[[FBSDKAppInviteContent alloc] init];
content.appLinkURL = [NSURL URLWithString:#"http://example.com"];
//content.appInvitePreviewImageURL = [NSURL URLWithString:#"https://www.example.com/my_invite_image.jpg"];
FBSDKAppInviteDialog *inviteDialog = [[FBSDKAppInviteDialog alloc] init];
if ([inviteDialog canShow]) {
inviteDialog.content = content;
inviteDialog.delegate = self;
[inviteDialog show];
}
This is what appears on the screen when the modal launches:
Does anyone know of any reason this would happen?
Edit[Sep 8, 2015 15:15 EDT]: We are currently getting an error code of 1; unknown error. Here is the exact print out:
Failed to perform app invite: The operation couldn’t be completed. (com.facebook.Facebook.platform error 1.)
Full Report => {
}
We thought it might be that we don't have friend permissions or something to do with iOS 9; however we are running our test on iOS 8, and we added friend permissions, and we have not seen a change.
I would call the validateWithError function they provided. It might give an idea of what the issue is.
FBSDKAppInviteDialog documentation

CoreLocation kCLErrorDomain error 5

I subclassed a CLRegion to support Polygons via overriding containsCoordinate: to use ray casting logic instead of the original distance crunching logic. The subclass is initialized via the normal method (initCircularRegionWithCenter:radius:identifier:), then CLLocationCoordinate2ds are added as NSValues to a mutable array. These coordinates are used during the ray casting logic.
As soon as I try to use the CLRegion subclass, I am confronted with a ton of errors in my application logic, as well as the following error:
2013-07-18 16:46:44.515 Geofencing[4816:907] (identifier 6C11CBAF-3EE4-4257-9D75-9724F4349B5D) <+39.86605072,-75.54420471> radius 186.54m: Error Domain=kCLErrorDomain Code=5 "The operation couldn’t be completed. (kCLErrorDomain error 5.)"
I also tried a different subclass that does not modify any methods but adds a method for reading metadata from an NSDictionary. I was confronted with the same error.
What is going on? Is subclassing CLRegion feasible?
I hate to answer my own question, but I have found the solution to my issue. A kCLErrorDomain code/error of 5 denotes that you have tried to monitor more than 20 CLRegions. In my case, both subclasses were guilty of monitoring more than 20 regions.
It also happens if you:
stop monitoring a region
[self.manager stopMonitoringForRegion:region];
and request the state for all monitored regions shortly afterwards:
for (CLRegion *region in self.manager.monitoredRegions) {
[self.manager requestStateForRegion:region];
}
you will get the kCLErrorDomain 5 because IOS seems to have disabled the monitoring for that region, but has not yet removed it from the monitoredRegions array
monitoringDidFailForRegion CLCircularRegion (identifier:'Home', center:<...>, radius:102.00m) The operation couldn’t be completed. (kCLErrorDomain error 5.)
monitoredRegion: CLCircularRegion (identifier:'Home', center:<...>, radius:102.00m)
monitoredRegion: CLBeaconRegion (identifier:'BeaconHome', uuid:<..., major:(null), minor:(null))
monitoredRegion: CLCircularRegion (identifier:'D...', center:<...>, radius:101.00m)
monitoredRegion: CLCircularRegion (identifier:'W...', center:<..>, radius:51.00m)
to work around that problem, do something like this:
- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
NSLog(#"monitoringDidFailForRegion %# %#",region, error.localizedDescription);
for (CLRegion *monitoredRegion in manager.monitoredRegions) {
NSLog(#"monitoredRegion: %#", monitoredRegion);
}
if ((error.domain != kCLErrorDomain || error.code != 5) &&
[manager.monitoredRegions containsObject:region]) {
NSString *message = [NSString stringWithFormat:#"%# %#",
region, error.localizedDescription];
[AlertView alert:#"monitoringDidFailForRegion" message:message];
}
}
Also: if you're testing with iBeacons, you can't use the iOS simulator.
It is also possible to get this error code back when your latitude and longitude values don't make sense. (I'd transposed them, for example, and was vexed by this error for a while.)
This error could also rise up if added CLRegion is nil.
If anybody is still struggling with this then take a look here:
In my case, I had to call requestAlwaysAuthorization just before calling startMonitoring and it worked like charm!
locationManager.requestAlwaysAuthorization()
let currRegion = CLCircularRegion(center: CLLocationCoordinate2D(latitude: LAT, longitude: LONG, radius: 100, identifier: "MyLocation")
currRegion.notifyOnEntry = true
locationManager.startMonitoring(for: region)
Btw, I would love to thank https://shrikar.com/swift-tutorial-corelocation-and-region-monitoring-in-ios-8/ for this.
I got this error because i did not start the Bluetooth.
So... do not forget to start your Bluetooth ;)

iOS 6 game Center

previously to me upgrading to iOS 6, I had gamecenter working as it should. Now I cannot seem to pass achievements to the gamecenter. The achievement happens, notifies the user with an alert but says "not achieved" in the game center. I have made a sandbox account and the app has not yet been reviewed.
This is how I was previously sending an achievement to game center:
[gameCenterManager submitAchievement:#"shareFacebook" percentComplete:100];
Is this not right anymore? I previously implemented this from the tutorial by mobile.tutsplus.com
Thanks in advance
This is how I'm doing it and seems to work well enough in iOS 6:
- (void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent
{
GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier: identifier];
if (achievement)
{
achievement.percentComplete = percent;
[achievement reportAchievementWithCompletionHandler:^(NSError *error)
{
if (error != nil)
{
NSLog(#"Error in reporting achievements: %#", error);
}
}];
}
}
Hope this helps!

PhoneGap, ChildBrowser, & Printing

OK, first the basics, I'm running cordova 1.5.0 (PhoneGap) with the latest version of ChildBrowser from the phonegap-plugins (the one compatible with cordova 1.5), Xcode 4.3.1 and iOS 5.1. Now the problem. I have code that works everywhere including a really basic test app to display and show an iOS Print panel. That is it works everywhere EXCEPT in PhoneGap. For the life of me, I can't get it to work. I assume it has something to do with the View Hierarchy created by PhoneGap and a PhoneGap Plugin.
In ChildBrowserViewController.h I added this:
- (IBAction)sendPrint:(id)sender;
And then wired this up to a button labeled Print (I know, I should use the system action button, for the sake of this problem I'm just trying to get it working). In ChildBrowserViewController.m I added the following implementation:
- (IBAction)sendPrint:(id)sender
{
UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printController.printInfo = printInfo;
printController.printFormatter = [self.webView viewPrintFormatter];
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error)
{};
[printController presentAnimated:YES completionHandler:completionHandler];
}
Note that this implementation is stripped down of all error checking for posting here, this is the minimal implementation that still works outside of PhoneGap.
I have been pulling my hair out for the last couple of days trying to get this to work to no avail. So I'm hopeful someone else has some idea, and given the number of people I've seen who want to add print to ChildBrowser, if I can provide a starting point,all the better.
BTW, it dies in objc_msgSend with an EXC_BAD_ACCESS (code=2,address=0x0). And I tried enabling Zombies with no additional help there either.
Thanks so much for any help.
Andrew

Game Center: authenticates ok, shows leaderboard ok, posts (my) score ok, only 2 players?

My game (called "Clear the Square") has gotten approved. It's getting hundreds of downloads. It's currently #44 in free word games in the US. There is only one problem: when I go to the Game Center leaderboards, it shows two users, one of them being me. And one of them being (very appropriately named) someone who isn't me. Here is a screenshot of what this looks like: http://clearthesquareapp.com/photo-9.PNG
I know that there are more than two people playing this (iAd tells me so.) I also know that the game is not unwinnable; somewhat challenging, but not unwinnable. And I know that Game Center didn't just completely go out of style overnight. In all other games that have ever been anywhere near a top-100 list, there are at least a few hundred all-time scores on the leaderboard.
Thinking that the problem might be that my development build is somehow special and goes to an alternate, "sandbox" set of leaderboards, I deleted the binary from my phone, rebooted my phone, and downloaded the game from the App Store. Same thing. So that wasn't the problem.
Here's all my GameCenter code; it comes straight from example projects. I don't know what could be missing, since it does successfully authenticate, it does show leaderboards, and it does post my score -- each time I set a high score, it is instantly reflected in the leaderboard.
I would really, really appreciate it if someone could download the free version of my game, and send me a screenshot of what the leaderboards look like on your end. You would definitely get promo codes for every future app I make.
- (void) authenticateLocalPlayer
{
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
[localPlayer authenticateWithCompletionHandler:^(NSError *error) {
if (localPlayer.isAuthenticated)
{
NSLog(#"authenticated in game center!");
// Perform additional tasks for the authenticated player.
}
}];
}
- (void) reportScore: (int64_t) score forCategory: (NSString*) category
{
GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
// handle the reporting error
}
}];
}
- (void) showLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController: leaderboardController animated: YES];
}
}
- (void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController {
[self dismissModalViewControllerAnimated:YES];
}
There should be more than two players on this leaderboard. What am I missing?
Edit: also, worth noting that it has already been out for about 48 hours, and probably has about 1000 downloads so far. So I am quite sure that it's not just a matter of nobody having had time to win a game yet.
You're probably still signed in to your "sandbox" Game Center account. Log out of that, and then log into your real account, and you should see the real leaderboards.
I ran into this problem myself, and it sometimes didn't "take" to log out and back in, so try a couple times. I think I may have had to kill (via the double-tap home button) the Game Center app after logging out of the sandbox, and before logging into the real account, for it to work.