Page 1 of 1

"Hi (username)"

Posted: Thu Jan 16, 2014 10:09 pm
by Victor Fagerström

I'm trying to make a label in my app say "Hi (username of the signed in user)" but I can't figure out how. I think somehow I need to get the username of signed in user as a response, how can I do that?

Please, don't just redirect to a tutorial, try explaining.


"Hi (username)"

Posted: Thu Jan 16, 2014 10:19 pm
by maxkatz

You are not sure how to get the signed user's user name?


"Hi (username)"

Posted: Thu Jan 16, 2014 10:22 pm
by Victor Fagerström

Yes, and being able to pass it to a label


"Hi (username)"

Posted: Thu Jan 16, 2014 10:37 pm
by maxkatz

Building Your First Mobile App quick-start tutorial: http://docs.appery.io/getting-started... shows you how to get data from a service and map it to a page or local storage.

Most of our tutorials show how to get data from a service.

You should also read REST API documentation, in particular: http://docs.appery.io/documentation/r...

Let's assume you keep the name in local storage. You can then read the value from local storage and set the value into a label using very simple JavaScript API: http://docs.appery.io/javascript-api/

Something like this:

var greeting = "Hello " + localStorage.getItem("name");
Appery("label_component").text(greeting);


"Hi (username)"

Posted: Thu Jan 16, 2014 10:51 pm
by Victor Fagerström

Yeah, but how can I get the username from database? Looking at the services I have at hand now only signup-service responds the username, which will only set localStorage var when new user is created, not on every log in.

Login service only responds userid and sessiontoken, could it also respond username of user logging in somehow?


"Hi (username)"

Posted: Thu Jan 16, 2014 11:47 pm
by maxkatz

You would need to do another request to get the user name. Or, you actually already have the user name -- if the user signed in successfully, then he/she enter the user name on the login form. Just save the value.


"Hi (username)"

Posted: Fri Jan 17, 2014 12:24 am
by Victor Fagerström

Nice, so annoying when you cannot figure it out yourself... Thank you Max, I got it working now :)