At 12/29/17 11:51 AM, PsychoGoldfish wrote:At 12/28/17 07:30 AM, dynamitewhale wrote:If you are already logged in, App.checkSession can be used to pull your user info without starting a new session.At 12/13/17 11:46 AM, PsychoGoldfish wrote:When I am testing the game in the preview mode, I am logged in.
The key part is the error you are getting back:
"error":{"code":0,"message":"Medal.unlock requires a valid user session."}
If the user isn't signed in, they can't unlock anything. See https://bitbucket.org/newgrounds/newgrounds.io-for-unity-c/#markdown-header-using-newgrounds-passport for information on how to sign a user in.
How can I test the API in the preview stage?
---
Do I need to start a session manually for badges to work? http://www.newgrounds.io/help/components/#app-startsession
Or does the core take care of that?`(there is somce code there that looks like it initializes the session on Start())
See http://www.newgrounds.io/help/passport/ for a break down of how all the session components are meant to work.
The Unity Library should handle all that if you are using it correctly though.
Are you trying to unlock a medal instantly just to see if it works? If so, you may be sending the API call before the user object has been loaded from the server. You shouldn't make any unlock calls until after your login stuff has called your onLoggedIn() method.
Hi PsychoGoldfish,
thank you for your support. You were totally right with your suspicion of me trying to call the API before the core was initilialized..
also I was trying to run logic in the same method as calling the API, and not in the callback - that's what caused most of my issues. After resolving that, it went much smoother.
I have a last question - it's not a blocker anymore, because I hacked my way around it, but I wanted to understand how the medal.unlocked property works.
If I check the medal.unlocked property in the callback, it is alwaysfalse.
If I get the list of medals, the medal has the "correct" value (either, true or false depending on whether the medal has been unlocked or not).
Is this intended?
I implemented an ingame medal-notification, and off course I only want it to show when unlocking the medal for the first time. But since the medal.unlocked value from the callback seemed broken I now do the following:
On startup get list of all medals
Make Dictionary of medals and their unlock status
Whenever I get a medal-unlock-callback, I check my dictionary of the medals whether it was unlocked or not, and show the notification.
Then I also update the status of the medal in my dictionary.
It works fine, but it feels quite hacky.