when we should enforce users to login at mobile app startup and when we can postpone it? What are the best practices for this?
It is very app dependent. A question to consider - what can an anonymous user accomplish. If you have some store, definitely allow to windowshop to get them hooked before they actually sign up. Same with any products that require some membership etc, show them as much as you can and then cash in (thus ask for data) as late as possible in the process.
If it is some business-related app / task app where you need to be logged in to access some restricted data, ask for a login before you can do anything else.
Depends on the context. And as for best practices, I don't think there is a yes or no answer to this. But there are definitely best practices around the login experience itself.
Let me illustrate 'context' with a few examples:
e-commerce: people might want to browse, add to cart etc and only if they decide to purchase it - they would want to create an account and login (and hope that their selected items added in their cart show up after logging in as well)
banking products: people cannot do much without logging in, only read supporting info/ product info.
newspapers/ journalism: sites such as WSJ, New York Times etc will show only a glimpse of the news article and will prompt you to login. They want to entice you, and have good quality journalism, but do not want to show the whole article for free.
As a user, I always like to look around and see if the app is for me before I create an account and give you my data.
You can give your users a unique ID based on their IMEI + Phone number and ask them for more details along the way after they used your app. When they are doing a checkout you can start asking for full information and build their profile with that data.
Basically, this depends on two main factors: 1. do we want to attract them with some content and 2. should they be able to access some content without logging in.
If the app is a part of a broader ecosystem the User knows then yes, we can require it. Especially when the expectations from the app are quite obvious (like FB Messenger, for example).
If we need to convince the User, what they can see in the app may be crucial factor for them to use it. But only if there is something to show—some interfaces depend on the data they need to input first.
In some cases we can present them pre-login content (like ecommerce platforms, where finding a product someone wants to purchase is the very trigger for them to log in or create an account. But sometimes users may be expected to have an account—e.g. if it's a company CRM, User accounts are usually created by administrators. Similarly about banking apps. In these cases, sometimes it would be great to at least show them what they can expect–via onboarding screens or some anonymous content.