Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

"Hi (username)"

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.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

"Hi (username)"

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

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

"Hi (username)"

Yes, and being able to pass it to a label

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

"Hi (username)"

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);

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

"Hi (username)"

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?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

"Hi (username)"

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.

Victor Fagerström
Posts: 0
Joined: Sun Dec 01, 2013 1:03 pm

"Hi (username)"

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

Return to “Issues”