Is there anyway to grant a virtual good to a player upon account creation as a "welcome gift"?
I do see that the Spark API has an "addVGood" method, so I'm guessing I can use this inside the AuthenticationResponse Cloud Code. Is that the right way to implement this, or is there some way to do this built into the Gamesparks Configurator that I don't see?
I had a typo in my post - I meant to say "RegistrationResponse" - not AuthenticationResponse.
If Configurator can't do this for me, I'm assuming RegistrationResponse is the right place to grant the good?
Does RegistrationResponse still fire even if the user is logging in from Facebook or Google and not creating an account via GameSparks RegistrationRequest? If not, how to grant a 'welcome gift' to first time logged in players via Facebook/Google/etc?
One way this could be managed would be through the use of an Achievement which is granted to the player in the RegistrationResponse. You could add the virtual good you want to grant to the player to said achievement in the Configurator and then award it to the player using Spark.getPlayer().addAchievement("shortCode");
The RegistrationResponse is only returned from the RegistartionRequest, every other form of Authentication returns the AuthenticationResponse. So in the case of Facebook Auth, etc you would check the AuthenticationRepsonse for a new player and award the achievement as required.
So basically just check if "isNew" in the AuthenticationResponse, and then give the player the virtual good at that time.
What about if I want certain segments to get different amounts of the good for signing up?
I'm guessing I should just use the SparkPlayer.getSegmentValue() manually to do this? Is that the best way, or is there a configurator screen for this somewhere I'm missing?
BTW, why did you recommend to use Achievements for this? Why not just give the user the gift directly using the addVGift? Am I missing something? Seems like an extra hoop to jump through without any benefit? Please forgive my ignorance..
I believe Ronan was referring to the SparkPlayer addVgood call. If you are setting a player to a particular segment on registration then you can get the value using the SparkPlayer.getSegmentValue() in the RegistrationResponse and then grant the gift based on this value. There is no built in way to award Virtual Goods on registration so it will require a little bit of Cloud Code.
Just to clarify - I will award the 'welcome gift' in 2 places in Cloud Code. Inside RegistrationResponse, AND, inside AuthenticationResponse (IF player isnew).
This would reward new players whether they register with the game or authenticate via facebook/google/etc, but never reward a player twice.
Apologies for the slow response. Yes you are correct on both counts there.
How do I ensure the good is always granted to every player in edge cases like a failure occurs?
Imagine a scenario where the Cloud Code has an error occur before the virtual good is granted. Or, for some reason, the call to addVGood fails.
Now this player is stuck and never got his welcome gift.
If I was building my own back-end, I would do this with a SQL database using a sql transaction. I would make sure the users account could not be created without the gift being given, if one fails, everything fails, like an atomic operation.
How would I achieve that in this scenario? Being that I'm not in control of the player getting added to the collection or the account details being updated to have the good?
Thank you for your help!