godot-ios-plugins icon indicating copy to clipboard operation
godot-ios-plugins copied to clipboard

Gamecenter not working

Open NeroNekro opened this issue 4 years ago • 2 comments

Hello there,

I try to use the GameCenter Plugin, but it not works.

I use this piece of code:

if Engine.has_singleton("GameCenter"):
        print("Gamecenter aktiv")       
        game_center = Engine.get_singleton("GameCenter")
        var login = game_center.authenticate()
        var result = game_center.post_score({ "score": 100, "category": "birds_4", })
        var show = game_center.show_game_center({ "view": "leaderboards", "leaderboard_name": "birds_4" })
    else:
        print("iOS Game Center plugin is not available on this platform.")

Without the part game_center.authenticate() I get the error "player is nil". With this part the game_center open on iOS. Is there any function to authenticate without open gamecenter?

In the documentation is the dictionary a litte bit unclear. On one section the key called "score" in another section "value".

Furthermore I get the following error:

ERROR: Condition "!p_score.has("score") || !p_score.has("category")" is true. Returned: ERR_INVALID_PARAMETER
at: post_score (plugins/gamecenter/game_center.mm:124) - Condition "!p_score.has("score") || !p_score.has("category")" is true. Returned: ERR_INVALID_PARAMETER

on this link you get a little project, with a gamecenter function and a in app purchase function. Both not working. https://1drv.ms/u/s!Ah2_A51TSFE1g7k0x5ylXLWFpLmoJQ?e=x1W2lU

thanks

NeroNekro avatar Dec 08 '21 23:12 NeroNekro

Without the part game_center.authenticate() I get the error "player is nil". With this part the game_center open on iOS. Is there any function to authenticate without open gamecenter?

You should always authenticate user to use GameCenter functionality. On real device GameCenter controller will display single time.

Furthermore I get the following error:

https://github.com/godotengine/godot-ios-plugins/blob/master/plugins/gamecenter/game_center.mm#L124 post_score should contain both score and category keys.

naithar avatar Dec 10 '21 07:12 naithar

Tested your project, I'm not getting the error that you have posted, but I'm getting script error:

2021-12-10 10:37:52.737761+0300 testapp[10264:10008889] 0
2021-12-10 10:37:52.737901+0300 testapp[10264:10008889] SCRIPT ERROR: Invalid operands 'String' and 'int' in operator '+'.
2021-12-10 10:37:52.738065+0300 testapp[10264:10008889]    at: _on_gamecenter_pressed (res://Control.gdc:50) - Invalid operands 'String' and 'int' in operator '+'.

You shouldn't use + sign for String and int which is result of methods, str(result) should help you with that.

Also category is a leaderboard identifier, not it's name, so this also can be an issue.

Edit:

Also, to test InAppPurchases you have to use TestFlight version of app or create StoreKit Configuration File, which will allow to test purchases in debug mode.

naithar avatar Dec 10 '21 07:12 naithar