Comments (11)
Not sure if you have figured this out yet, but for anyone else having this problem it would appear that the function _on_sign_in_success()
actually requires a parameter in order to be recognized. So the following does work successfully:
(Note: I prefer to use typed GDScript, so the extra "fluff" can be removed if you want)
func _on_sign_in_success(id : String) -> void:
print("hello from _on_sign_in_success\nID: %s" % id)
The id
parameter that is given looks to be the ID for the Google User.
Similarly, the callback for _on_player_is_already_connected()
requires 2 parameters. So the following will work:
func _on_player_is_already_connected(status : bool, id : String) -> void:
print("hello from _on_player_is_already_connected\nStatus: %s | ID: %s" % [status,id])
The status
parameter is either true or false depending on if the user is connected or not, and the id
contains the ID once again and should match the one from _on_sign_in_success()
. Hope this helps!
from pgsgp.
After some additional testing:
If there is a problem with the auth (wrong sha1 or user just declines google permissions request to use google drive, etc), _on_sign_in_failed callback works and returns an error code. If sign-in is successful, _on_sign_in_success is not called. If the phone is not connect to the internet, the sign-in is still successful - I guess GPGS client libraries do some kind of caching/proxying for the internet connection.
Also, _on_player_is_already_connected doesn't get called (I'm trying to call is_player_connected() somewhere after sign_in()).
My idea is to use is_player_connected to determine if some score related gui itens will be visible or not.
from pgsgp.
I've ended up releasing my game without using this function. But I would like to use on my next one so, this is extremely useful.
How can I know the user ID for checking if he signs in successfully? Do I have to provide the ID when signing in, or is the ID provided by the callback _on_sign_in_success?
Thank you!
from pgsgp.
@cgeadas I have updated Read me. You can check the correct callback. You don't need to provide the id when signing in. Correct signature of the _on_sign_in_success callback is: func _on_sign_in_success(account_id: String) -> void
Please try again and check if it is working now. Keep in mind to download the latest plugin from tag 1.2.0 (https://github.com/cgisca/PGSGP/releases/tag/1.2.0).
from pgsgp.
EDIT: I'm submitting an official request to change is_player_connected() to immediately return a result (synchronous) rather than use a callback (asynchronous).
I'm encountering an issue where my app works fine when loaded from Android Studio but does not work when installed from the Play Store. The issue is the spaghetti-code I've had to write just because is_player_connected() uses a callback. The problem is normal code branching based upon the return from is_player_connected() can't be used because of the callback strategy.
Ideally I should be able to write
func _ready():
If !gpgs.is_player_connected():
gpgs.sign_in();
else:
# do other stuff...
from pgsgp.
@cgisca _on_sign_in_success callback is working ok. However, is_player_connected never triggers the callback.
On a side note, I agree with @tx350z about synchronous results. If it is possible to make it synchronous, it would make my programming much simpler and "clean" than going around with weird gymnastics because of the callbacks. But then, if it programmed like this, it's because it probably has to be like this.
from pgsgp.
Actually it doesn't have to use callbacks for everything. I added synchronous versions of is_player_connected(), save_snapshot(), and load_snapshot() to the plug-in Java code.
from pgsgp.
@tx350z I (still) don't speak Java :-) so I can't adapt it completely to my needs. Meanwhile, I'll try to deal with the callbacks with a mix of signals and yields - maybe that can work in a manageable way - meaning I'll still be able to understand my code in a few months from now.
from pgsgp.
Be aware that yield() will not be included in Godot 4.0. Hopefully there will be something similar to allow cooperative multi-threading.
from pgsgp.
@tx350z Thank you for the heads up. I was not aware of that change. I really hope they come up with something useful - sometime those guys are so short-sighted... :-(
from pgsgp.
_on_player_is_already_connected
I can not a find a signal for this...
from pgsgp.
Related Issues (20)
- Error 12501
- Error 4 when sign in with app on production HOT 1
- Need an update for 3.2.4 HOT 5
- Unable to get the module to work for Godot-3.2.2. HOT 1
- [Feature Request]Getting leaderboard data for internal leaderboard
- How to retrieve idToken on sign_in function
- account_id parameter in _on_sign_in_success() always null and does not print HOT 2
- Stuck forever after tapping on account to sign in if using initWithSavedGames instead of just init HOT 5
- [CAUSED BY DEPRECATED API] Only works with default configuration and Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration HOT 2
- fun isSignedIn(): Boolean .. can't react on this with c# HOT 1
- 2 crashes: com.google.android.gms.tasks.RuntimeExecutionException and io.cgisca.godot.gpgs.accountinfo.PlayerInfoController$fetchPlayerInfo$1.onComplete
- Nonexistent function 'init' in base 'JNISingleton'. HOT 7
- Godot cannot be cast to android.app.Activity HOT 7
- godot didn't work in 3.3.2
- How can I get this to work on 3.3.2?
- Fatal exception on Godot 3.3.2 HOT 1
- Update to 3.4.2 HOT 1
- how to use this in flutter application
- play_games_services.signIn() causes a crash
- PGSGP: How works backend token verification?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgsgp.