Leaderboard "No Items" - iphone

I'm trying to implement GameCenter to my app.
This is to show me the GameCenter LeaderBoard but it's shows me: No Items.
-(IBAction) ShowLeader{
GKGameCenterViewController* gameCenterController = [[GKGameCenterViewController alloc] init];
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
gameCenterController.gameCenterDelegate = self;
[self presentViewController:gameCenterController animated:YES completion:nil];
}
The user is authenticate and that's show up when i connect.
when i report score in my GameViewController:
if ([GKLocalPlayer localPlayer].isAuthenticated) {
GKScore* scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier:#"GameHighScore"];
scoreReporter.value = HighScoreNbr;
scoreReporter.context = 0;
// NSArray *scores = #[scoreReporter];
[GKScore reportScores:#[scoreReporter] withCompletionHandler:^(NSError *error) {
if (error) {
NSLog(#"error: %#", error);
}
printf("no error: ");
}];
}
This shows me no error so i suppose it works.
I already tried with 2 accounts since i saw that on other answer but didn't help.
If you need any more info please comment.
Thanks.

I found out myself after reading and viewing tones of video.
if that can help someone who as the same problem:
you need to had your BundleID from Itunes connect to your xcode5 info playlist.
then it should work.
Hope it helps ;)

This can also happen if gamekit is missing from Required device capabilities in your plist.

Related

iPhone App Crash with error [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:]

I have an iPhone App in the app store which is using Touch ID. If Touch ID is enabled, the user is authenticated with it, else user needs to enter his PIN to login to the application.
After IOS 10.1 release, when I checked the crash report, the crash count has increased. From the crash report, it is pointing on [UIApplication _cachedSystemAnimationFenceCreatingIfNecessary:] and when I opened the app in Xcode, it is focussing on [self dismissViewControllerAnimated:YES completion:nil];.
The code I have written is as below:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(#"User is authenticated successfully");
[self dismissViewControllerAnimated:YES completion:nil];
} else {
}];
}
}
When I tested in iPhone 6, IOS 10, everything is working fine. Don't know how to simulate the issue.
Can anyone please figure out if I am missing something? Please help me out in resolving this crash issue.
Usually completion handlers are not running on main thread. All UI related stuff must be done on main thread (including dismissing a view controller).
I suggest to add the dismiss line on a main thread block like this:
-(void) showTouchIDAuthentication{
LAContext *myContext = [[LAContext alloc] init];
NSError *authError = nil;
NSString *myLocalizedReasonString = #"Authenticate using your finger to access My Account Menu.";
if ([myContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&authError]) {
[myContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:myLocalizedReasonString
reply:^(BOOL success, NSError *error) {
if (success) {
NSLog(#"User is authenticated successfully");
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
[self dismissViewControllerAnimated:YES completion:nil];
}];
} else {
}];
}
}

Unable to implement a custom Facebook login button for IOS

I am trying to create a custom login button for IOS 9,i have been following the Facebook's tutorial for doing so but when i button is clicked,i end up getting this error
libc++abi.dylib: terminate_handler unexpectedly threw an exception
I have been following this Facebook tutorial,only difference is i am using dispatch_async due to some reasons.
https://developers.facebook.com/docs/facebook-login/ios#loginkit
dispatch_async(dispatch_get_main_queue(), ^{
NSMutableArray* Permissions = [[NSMutableArray alloc] init];
[Permissions addObject:#"email"];
[Permissions addObject:#"public_profile"];
FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
[loginManager logInWithReadPermissions:Permissions
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
NSLog(#"Process error");
}
else if (result.isCancelled)
{
NSLog(#"Cancelled");
}
else
{
NSLog(#"Logged in");
}
];
});
I have tried using Parse SDK's code too like so...
NSArray *permissionsArray = #[ #"user_about_me", #"user_relationships", #"user_birthday", #"user_location"];
[PFFacebookUtils logInInBackgroundWithReadPermissions:permissionsArray block:^(PFUser *user, NSError *error)
{
if (!user)
{
NSLog(#"Uh oh. The user cancelled the Facebook login.");
}
else if (user.isNew)
{
NSLog(#"User signed up and logged in through Facebook!");
}
else
{
NSLog(#"User logged in through Facebook!");
}
}];
But both the time,i end up getting the same error like as shown in the image below..
Error message image
Am i doing something wrong in app validation process?
Please help!
Thank you!
This is weird,after playing around in Xcode,i found that it is not able to get my appID and other settings from my plist even though it's there.After i programmatically set my app id using
[FBSDKSettings setAppID:#"appid"];
[FBSDKSettings setDisplayName:#"displayname"];
I was to able get rid of that error,but i am stuck at URLSchemes...i will recreate the project and try again!
Thank you!
It's working now and,i am able to get a login page,but after i get past the app login screen,i am getting a blank white screen with only a done button at th top right corner,when i click it,i get the log message that the user cancelled login.

Problems With Game Center

Just finished my first iOS game (mostly). Its all ready to go, just need to link in Game Center. This however, is proving to be ...annoying. My App is all registered on iTunes Connect, and all the Game Center code is taken directly from Apple. So why is NONE of this working?
First: authentication always fails;
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) {
if ([GKLocalPlayer localPlayer].authenticated) {
// authentication successful
}
else if (loginVC) {
// player not logged in yet, present the vc
[self presentViewController:loginVC animated:YES completion:nil];
}
else {
// authentication failed
}
};
With error "The requested operation has been cancelled"
As a corollary, trying to present a game center vc in the future yeilds a "Player is not signed in message"
Second: this
GKScore *score = [[GKScore alloc] init];
if (score) {
score.value = self->selectedScore;
NSArray* scoreArray = [[NSArray alloc]initWithObjects:score, nil];
//score.category = #"High Scores";
UIActivityViewController *avc = [[UIActivityViewController alloc]
initWithActivityItems:scoreArray applicationActivities:nil];
avc.completionHandler = ^(NSString *activityType, BOOL completed) {
if (completed)
[self dismissViewControllerAnimated:YES completion:nil];
};
if (avc)
[self presentViewController:avc animated:YES completion:nil];
}
yeilds a 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
What am I fundamentally doing wrong? Thanks to anyone who can offer any help.
Try to log out/in in the Game Center application with your test user account.
Check this answer: https://stackoverflow.com/a/4420457/89364

Game Center inviting friends programmatically

I'm facing difficulty inviting a friend to the match.
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 2;
request.playersToInvite = [NSArray arrayWithObjects: #"G:1102359306",nil ];
// GKMatchmakerViewController *mv = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
// [self presentModalViewController:mv animated:YES];
[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) {
if (error) {
NSLog([error description]);
}
else if (match != nil) {NSLog(#"good match");
//self.chatMatch = match;
//self.chatMatch.delegate = self;
//[self chatReady];
}
else {
NSLog(#"other error");
}
}];
The problem is I never receive the invitation notification on second device logged to the account - G:1102359306.
When I use GKMatchmakerViewController (uncomment above 2 lines) and comment GKMatchmaker block I have automatically checked the good friend - G:1102359306 and when I invites him the notification with accept/decline is shown, that's how I know it's correct.
Do you see anything wrong with the code above? I want to use my own UI to handle the multiplayer mode. The strange problem is I also don't see in console any logs good match/other error, and the [error description] is only printed when I call the above code twice - it says that the previous req was canceled.
You cannot programmatically invite a specific set of players to a match. The findMatchForRequest:withCompletionHandler: documentation says this:
The match request’s playersToInvite property is ignored; to invite a specific set of players to the match, you must display a matchmaker view controller.
There is no public API that does what you want.

CMMotionManager and the Gyroscope on iPhone 4

I am trying to simply NSLog the output of the new iPhone 4 Gyroscope. But after reading the documentation and following their sample code I am getting this error.
ERROR,Time,300635803.946,Function,"CLLoggingSetFile",could not open locations log /var/mobile/Library/Caches/CoreMotion/CoreMotion.log
Even if I just setup my motionManager object with [[CMMotionManager alloc] init]; on its own and no other code, I still get the error.
Here is my .h file.
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
#interface GyroTest0ViewController : UIViewController {
CMMotionManager *motionManager;
NSOperationQueue *opQ;
}
#end
And here my .m file.
- (void)viewDidLoad {
[super viewDidLoad];
// the error occurs even just with this line on its own
motionManager = [[CMMotionManager alloc] init];
if (motionManager.gyroAvailable) {
motionManager.gyroUpdateInterval = 1.0/60.0;
[motionManager startGyroUpdates];
opQ = [[NSOperationQueue currentQueue] retain];
CMGyroHandler gyroHandler = ^ (CMGyroData *gyroData, NSError *error) {
CMRotationRate rotate = gyroData.rotationRate;
NSLog(#"rotation rate = [%f, %f, %f]", rotate.x, rotate.y, rotate.z);
};
} else {
NSLog(#"No gyroscope on device.");
[motionManager release];
}
}
Any help and/or source code to simply log the iPhone 4 gyroscope data would be much appreciated. Many thanks!
Try this,
motionManager.gyroUpdateInterval = 1.0/60.0;
[motionManager startGyroUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMGyroData *gyroData, NSError *error)
{
CMRotationRate rotate = gyroData.rotationRate;
NSLog(#"rotation rate = [%f, %f, %f]", rotate.x, rotate.y, rotate.z);
}];
For the WWDC sample code:
Log in to ADC
Click on WWDC 2010 session videos
View in iTunes
There you find the link to sample code (230 MB)
Any results regarding this issue? I get the same error even when I use WWDC teapot demo code.
I filed a bug report (8382659).
By the way I get the same error when I use the push method described by Joshua Weinberg.
Update: Apple confirmed the bug but referred to a duplicate issue 8173937 that I can't find. Well let's hope that it will be fixed in the next release.