I am developing an Xamarin forms (Android and iOS) applicaion and checking the logged in status when application starts and assign the appropriate values if the user already logged in to application. This process takes 6 seconds to load the first page in our application. I have followed the Xamarin Auth to store the credentials of the user when logged in.
Below is the procedure to store and retrieve the details of logged-in user that I've used in the application.
https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/general/store-credentials/
Code snippet which is used in OnStart method of App.cs file:
protected async override void OnStart()
{
LoginType login = DependencyService.Get<ILoginCredentialStorage>().LoginExists();
this.MainPage = new NavigationPage(new HomePage(login));
}
How can I reduce time to load the first page in application?
Use fast Renderers Fast renderers reduce extensions and rendering the cost of controls on android by flattering the resulting native control hierarchy. It also improves performance by creating fewer objects, which turns results in a less complex visual tree and memory use.
Startup Tracing If you go into the Android Options of your Xamarin projects, you'll see this: If you enable the AOT Compilation (Ahead of time), your app performances will improve significantly and so the startup time, but your apk size will increase as well.
Since its appearance in 2011, Xamarin has become a great option for cross-platform app development, a faster way to build iOS, Android, and Windows apps.
You probably need to move the getting of the login credentials to the login page, and leave it as late (i.e. OnAppearing rather than the constructor) as possible to do that so you can show a progress indicator.
Here are some more tips
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With