Facebook Leaderboard and Login Problem iOS Cocos2d

0 votes

Hello there.

I followed this tutorial

http://api.shephertz.com/tutorial/iOS-leaderboard/?index=leaderboard-sample

I first had some troubles with the button, there's no such button named Login_facebook.png

in the FacebookSDKResources.bundle , so used this one FacebookSDKResources.bundle/FBLoginView/images/login-button-small.png 

anyway i registered as a FB developer and added my FacebookAppID to my info.plist file, then copied the App42Helper and Leaderboard folders to my project. Setted the app and secret key , and the game level in LDConstants and added 


    [[App42Helper sharedApp42Helper] initializeApp42];

 

in my 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

 

Lastly i just created a cocos2d button / menu that when is pushed this happens

 

    [[PWFacebookHelper sharedInstance] setDelegate:self];
    [[PWFacebookHelper sharedInstance] openSessionWithAllowLoginUI:YES];
    NSString *anID = [[PWFacebookHelper sharedInstance] userId];
    NSLog(@"facebook id %@",anID);

 

 

When i push the button in game, i get redirect to facebook and asked for a login, then for permissions.

I do all that, but the NSLog always displays facebook it NULL and also the protocol functions 

 


-(void)fbDidNotLogin:(BOOL)cancelled;
-(void)userDidLoggedOut;
-(void)userDidLoggedIn;

are never called! 

 

Also i get these logs when  i push the button:

 

16-04-19 09:56:26.736 Save The Penguin[8019:1312941] openSessionWithAllowLoginUI response
2016-04-19 09:56:26.736 Save The Penguin[8019:1312941] userInfoDict=(null)
2016-04-19 09:56:26.736 Save The Penguin[8019:1312941] self.userName=(null)
2016-04-19 09:56:26.747 Save The Penguin[8019:1312941] error=(null)
2016-04-19 09:56:29.410 Save The Penguin[8019:1312941] facebook id (null)
2016-04-19 09:56:30.478 Save The Penguin[8019:1312941] LaunchServices: ERROR: There is no registered handler for URL scheme fbauth

 

 

What am i missing? 

Thanks a lot, 

Gabriel

 

Ps. all the testing are made on the simulator, ios 9.2

asked Apr 19, 2016 in App42PaaS & BPaaS by differentsparksgames (10 points)

1 Answer

0 votes

Hi Gabriel,

In the sample, the parameters which is null is fetched from the NSUserDefaults and printed. If this informations are not available in the same it will print null.

The above methods are called using the delegate instance in PWFacebookHelper class, so make sure this instance is not nil.

Please look into the same sample from this link which I have updated and running fine at my end.

Let me know if you have any queries.

Thanks.

answered Apr 19, 2016 by rajeev.etc (1,660 points)
Ok so i got to modify the way it stores the info. in my game am  not using     NSUserDefaults. but am i actually logged in ?

About the methods that are not being called, I'm calling
[[PWFacebookHelper sharedInstance] setDelegate:self];

so the delegate instance in PWFH shouldn't be nil.

I still don't understand why in the sample it finds the button but in my project doesn't. and i checked in the bundle, there's not.

Thanks for the reply :)
The image Login_facebook.png is added by us in the sample project. It is not provided by the FacebookSDKResources.bundle. You can find this image in the sample under the group LeaderBoardImages.
Thanks for the tip
Ok i think it works now, i just replaced all the files and copied again from the sample you linked me. the protocol's methods works too, but it seems doesn't find the username, is it normal?

userInfoDict={
    id = 102xxxxxxxxxxxx;
    name = "Gabriel xxxxxxxxxx";
}
2016-04-21 00:50:37.856 Save The Penguin[17554:3190719] Facebook in
2016-04-21 00:50:37.856 Save The Penguin[17554:3190719] self.userName=(null)
2016-04-21 00:57:26.185 Save The Penguin[17673:3203156] error=(null)
self.userName in the sample is the user's first_name on facebook. If you will not get the same from facebook it will be null in the sample. In the log you are only getting id and name param from your facebook account. With the same sample, i am able to get following information:

userInfoDict={
    birthday = "********";
    email = "*************";
    "first_name" = ********;
    gender = ********;
    id = *********;
    "last_name" = *********;
    link = "***********";
    locale = "en_US";
    location =     {
        id = **********;
        name = "***********";
    };
    name = "*************";
    timezone = "5.5";
    "updated_time" = "2013-08-23T07:27:20+0000";
    verified = 1;
}
Could it be so because of missing permissions ?
Come on man help me out :(
Still can't get the correct username, if i access it from score.userName it gives me the Facebook id, not really useful for a leaderboard.
And calling
[[[PWFacebookHelper sharedInstance] loggedInSession ]isOpen]

always return NO.

Also tried to post on the wall,by calling:

    [[PWFacebookHelper sharedInstance] postWithText:@"test" ImageName:@"null" URL:@"test.com" Caption:@"null" Name:@"test" andDescription:@"description"];

it actually does the post on my Facebook wall but in game it prompts the message
[img]http://i.imgur.com/mmrePpv.png[/img]

Am i experiencing all those problems because of the old Facebook SKD? Or could be the simulator?
i copied the files from the sample project you linked me, it's getting very frustrating .
Thanks, Gabriel
Hi Gabriel,

The sample has used fb_id as the user name to save the score to maintain the uniqueness for user name. If you can see the saveScore method of App42Helper.m class, it is saving some extra information including the name of the user along with the score.

While getting the score in the getScores method of same class, the sample is able to get the extra information as well which is later used to show in the leaderboard.

Regarding the other issue, yes, it can be the SDK as the facebook has changed a lot. So , i will suggest you to use the latest facebook SDK and its APIs.

Thanks,
Rajeev
Thanks, for the support.
But i'm going to leave App42 platform. is unbelievable that you guys offer a ready to use social platform 3 years old.
Gabriel
Hi Gabriel,

The sample was created and tested with older Facebook app and the supported Facebook SDK for those apps. That's the reason you faced this issue. we were in the process of updating our samples. We take your request on higher priority and update this sample in a couple of days.


Regards,
Rajeev
Wow, that would be awesome and unexpected.
Hope to hear good news from you guys soon.
Thanks again,
Gabriel.
Hello, sorry to bother you but i'd like to now the status of the updated sample.
I stopped working on my own integration because of what you said.
Let me know if the updating process is still planned.
Thanks again,
Gabriel
Hi Gabriel,

Please download the updated sample project from here(https://www.dropbox.com/s/f921qepdf7r37n6/LeaderBoardSample.zip?dl=0) and let me know if you still have any concerns. I will be happy to help you!!

Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...