At 12/28/17 07:30 AM, dynamitewhale wrote: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())
If you are already logged in, App.checkSession can be used to pull your user info without starting a new session.
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.