iOS + GameCenter / iOSkit

Hello,

I would like to use Gamecenter/Leaderboard on Xojo.

I am struggling with handling GameCenter using iOSkit.
Logging in is OK, (maybe) I can send my score, but I cannot show Leaderboard.
Anyone can open Leaderboard on Xojo?

BTW, if interested, see my Xojo iOS alarm app here: http://suzu.ltd/en/waatanalarm/

Tutorials are your friend for this. Lookup Ray Wenderlich for his gamekit tutorials. Another good outline of what to do in iTunes connect is here:
https://www.appcoda.com/ios-game-kit-framework/

Hi Jason, nice to meet you! Your library is so great!
I am working on

AchievementAndScoreHelper.DisplayLeaderboard method.
It has 2 args and I have no idea what I should pass for the first one.

Dim v As iOSview
v = New iOSView( )
App.aas.DisplayLeaderboard( v, “game001LB” )

this code works, but v is shown and do not get Leaderboard.
passing Self instead v crashes.
I wonder what should I pass for the first argument…

Any sample code or ideas?

Hi Yoshitaka,
Glad you are enjoying the library!

You should be using self as the parameter. Would you be able show the crash log (available by pressing cmd-/ in the simulator, or through the devices menu in Xcode from your phone/ipad)? That would help me to direct you on what needs to be changed, it is possible there is an error in my implementation.

Jason

Hi, This is what I get. Let me know if you need more info.


Dec 22 08:46:23 MBP2015-4 game001.debug[20854]: *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Application tried to present modally an active controller <GKGameCenterViewController: 0x11a06a000>.’
*** First throw call stack:
(
0 CoreFoundation 0x0000000105a41b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000103d8e141 objc_exception_throw + 48
2 UIKit 0x0000000100609194 -[UIViewController _presentViewController:withAnimationController:completion:] + 5146
3 UIKit 0x000000010060be8a -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
4 UIKit 0x000000010060b962 -[UIViewController presentViewController:animated:completion:] + 181
5 game001.debug 0x00000001000a6885 UIKit.UIViewController.PresentViewControllerAnimatedCompletion%%o<UIKit.UIViewController>pbo + 1125
6 game001.debug 0x00000001000963cd AchievementAndScoreHelper.DisplayLeaderboard%%ooy + 1245
7 game001.debug 0x000000010011ade3 View1.View1.Button1_Action%%o<View1.View1>o + 915
8 game001.debug 0x000000010011c8f4 Delegate.IM_Invoke%%o + 52
9 game001.debug 0x00000001000ac964 AddHandler.Stub.2%% + 52
10 rbframework.dylib 0x00000001058052e7 SQLiteDatabaseField_IsNull + 1223
11 UIKit 0x0000000100454d82 -[UIApplication sendAction:to:from:forEvent:] + 83
12 UIKit 0x00000001005d95ac -[UIControl sendAction:to:forEvent:] + 67
13 UIKit 0x00000001005d98c7 -[UIControl _sendActionsForEvents:withEvent:] + 450
14 UIKit 0x00000001005d8802 -[UIControl touchesEnded:withEvent:] + 618
15 UIKit 0x00000001004c27ea -[UIWindow _sendTouchesForEvent:] + 2707
16 UIKit 0x00000001004c3f00 -[UIWindow sendEvent:] + 4114
17 UIKit 0x0000000100470a84 -[UIApplication sendEvent:] + 352
18 UIKit 0x0000000100c545d4 __dispatchPreprocessedEventFromEventQueue + 2926
19 UIKit 0x0000000100c4c532 __handleEventQueue + 1122
20 CoreFoundation 0x00000001059e7c01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
21 CoreFoundation 0x00000001059cd0cf __CFRunLoopDoSources0 + 527
22 CoreFoundation 0x00000001059cc5ff __CFRunLoopRun + 911
23 CoreFoundation 0x00000001059cc016 CFRunLoopRunSpecific + 406
24 GraphicsServices 0x0000000105e4ea24 GSEventRunModal + 62
25 UIKit 0x0000000100453134 UIApplicationMain + 159
26 rbframework.dylib 0x0000000105756abd GetIOSAppWindowHandle + 2334
27 game001.debug 0x00000001000012ed Xojo._RuntimeRun + 29
28 game001.debug 0x000000010011e28d _Main + 749
29 game001.debug 0x000000010011d5f3 main + 19
30 libdyld.dylib 0x000000010670865d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)


My code there: (aas = AchievementAndScoreHelper )

App.aas.DisplayLeaderboard( Self, “game001LB” )

I hope it helps.

Yoshitaka

Are you using a tab bar?

You mean a Navigation bar?
In my test project, the View1 has a button only, no navigation bars.

This is the error. I can do some searching tomorrow but I would google this and see if there is anything useful on resolving it.

Thank you very much for your reply. I am waiting your your reply since I am no good at Objective-C thing.
BTW, here is the project for testing : http://suzu.ltd/g1.zip

And No, I do not use Tabbar (I understand what TabBar is now… sorry)

I will take a look later today and let you know what I find.

I’ve identified the issue and pushed a fix to github. If you would like me to send you the example project back I can do so in PM.

Hi Jason,

Thank you very very very much for your fix! It works great!
Now I can easily continue working on my iOS game.
Thank you very much again for your great library!!

And Happy Holidays!

Good luck with the rest of your game and happy holidays to you too!

[quote=365784:@Jason King]Tutorials are your friend for this. Lookup Ray Wenderlich for his gamekit tutorials. Another good outline of what to do in iTunes connect is here:
https://www.appcoda.com/ios-game-kit-framework/[/quote]
I didn’t want to open a new thread for this. Just have a question regarding the iOS Kit. First of all, it’s absolutely awesome! I don’t understand much of the code but I can still interact with GameCenter. Terrific work, thank you!

In the link above it is mentioned that you can reset the leaderboard in GameCenter. Is there some code for it in the iOS Kit? I haven’t found anything on that. Thank you!

Glad you are finding the module useful! Resetting the leaderboard isn’t possible with the code in iOSKit. I believe it must be done through iTunes connect. I’ll be honest that I’ve never tried that before

Thanks for your reply, Jason. I was wrong, I misread the article. It says “Resetting the achievements” and that is in your code. I find your iOSKit and Jeremy’s iOSDesignExtensions extremely useful and I want to thank you again for that. Is there a way I can donate to show my appreciation? Didn’t find anything on GitHub.