You need to save the user's device id information to the database. Only when they call the logout API will they log out, otherwise when you open the app, you check if the device id has been logged in on the database.