Is there a way to check if user logged in

0 votes
Hi, In my app I need to check if user logged in, if not go and login. Is there a way to check it? Thanks
asked Feb 21, 2016 in iOS by victorshablyko (11 points)

1 Answer

+1 vote

Hello Victor,

I have upadetd the sdk with getLoggedInUser API in App42API class which you can call as follows:

[App42API getLoggedInUser]

If you are using  createUser API of User Service then on successfull user creation, you can use the above API every time you open your app to check if user is loggedIn.

You can aslo set loggeIn user manually as follows:

[App42API setLoggedInUser:@"Your user name"];

You can get the user later on as stated above.

Please download the latest SDK from here.

Let me know if you face any problem.

Thanks.

answered Feb 22, 2016 by rajeev.etc (1,660 points)
Thank you Rajeev, while waiting I did this way, on registration success I saved sessionID and then using "sessionService getSession" I got session id and compare it with earlier saved one, if it is the same - user logged in, if not - need to login. Will it work or better update sdk and use "getLoggedInUser" method?
Yes, this will also work. Also, please make sure to update the locally saved session Id whenever user logs out or logs in.
Thanks, so sdk changes sessionID every time user log out/in. Can you please tell me, does sdk automatically logout user? For example, if user logged in and then use my app after a month will he still be logged in? And what if user shut down app completely from iPhone memory does SDK log out in this case? Thanks again
No, user will not be logged out until he calls logout api. Once he calls logout the session on the server will be removed and the session id will be deleted. In this case you also need to clean sessionid after logout success if you are saving on your app level.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...