Unity: stay mobile

I am new to Unity. I am currently developing my first game for IOS and Android. I am at the point where I want my users to register and log in. I will store their data in a mysql database. This works great. However, I am lacking basic knowledge of this procedure for mobile applications in general.

If the user signs up and logs in and closes the app, how do I handle their session? In games like Clash of clans, you basically sign up once and log onto your mobile all the time, even if you uninstall the app and download it again.

How is this handled in Unity mobile apps? In PHP I would just use session and / or cookies for this. But as I said, I lack basic knowledge of how this is done in mobile games.

Basically, I want to know how to distinguish players by their IDs and make them register once with their phone and stay online forever, at least until they log out. How do I create these sessions?

Any help would be appreciated.

Have a nice day!

+3


source to share


1 answer


in ios and android, android, when you press the home button and ios, when you press the circle button, it lights up

 void OnApplicationPause(bool pauseStatus) {
        paused = pauseStatus;
        //do your sign in and sign out work
    }

      

when it runs this method in your game and the user is down for a certain period of time, usually the login and logout service will log out, so you should have a way to check if your service was signed or not

isSignedIn();

      

using this in if {} you can auto login or not use OnApplicationPause () method



for Android if they hit the back button

if(Input.GetKeyDown(KeyCode.Escape)){}

      

then this will completely terminate your application, so when they open the application it will start from your initial loading screen, after which you can silently authenticate them during the registration process, same for ios if you are using

Application.Quit() 

      

enter your game

+1


source







All Articles