Implement Auto Login in HomeScreen - flutter

I currently have implemented auto login, there is only a slight problem.
If a user logs in, I save their data in SharedPreferences.
Now, when the re opens the app it opens to the login screen makes an API call to check if the login is successful with the current SharedPreferences credentials.
Then if it returns 200 it pushes them to the home page of the application.
The problem is that there is a slight delay when the user opens the app because the user is authenticating with the backend. So we see the login page for 500ms and then it pushes to the home page.
How can I use a splash screen or something so we dont have this awkward 500ms delay.

Use a FutureBuilder on your Login page. Show your splash screen while the future resolves, show the Login page if it did not succeed, navigate to the next page if it did.
Example for using a Future with a FutureBuilder:
What is a Future and how do I use it?

Related

Auto Login using flutter when using FirebaseAuth

I want to auto-login every time the app starts, I am using FirebaseAuth, so my userid is auto-fetched, but it goes to the registration page directly, I want to check if the user exists or not if it exists, move it to the home screen else to the registration page.
I know what to do, but where to check this and so navigation?
What you're looking for is what we usually call a Splashscreen.
That's the screen you usually see on huge app's startup, with a loader.
On this screen, you can do all the stuff that is required for your app to run correctly :
Preload your images.
Load some datas from an API
Check the user's state
That's the good place to choose to redirect your user toward the most appropriate screen

Launching application with different Activities at different situations

I am working on an application where I have to launch activity asking user to enter login and password to proceed further. The user will get option to save login/password. If user saves login and password, the application will not show login activity at next launch and instead should go directly to the main application screen.
I am thinking of starting application with Application class object and checking stored preferences to decide which activity is to launch. For some reason, application class is not launched, it may need some extra thing in manifest file.
Any suggestions what would be the best way to implement this kind of behaviour.
Thanks
Bsengar
Any suggestions what would be the best way to implement this kind of behaviour
A splash screen is often used for this. Your first Activity (splash screen) can display your logo/and or play music or whatever while you check your data and decide which Activity to go to next like login or main Activity. This usually shouldn't be displayed very long (maybe less than a second or so unless doing network stuff such as authenticating/loading data).
...and checking stored preferences to decide which activity is to launch
This is often how people handle this. You can check SharedPreferences in your splash screen to decide which Activity to start. If the login is stored then go to main Activity. If not then go to your login Activity.
Make sure to call finish() in your splash screen so if the user presses the back Button from login or main Activity they will exit the app instead of going to the splash screen again, unless of course that's what you want.
Good example of getting started with SharedPrefs in case you aren't familiar.
Full Docs for SharedPrefs
I wrote an application that does something very similar. In my case, I use a "remember me flag" that allows the user to indicate that they want the application to save the login id and password. If they elect this setting, the application will save the login information in preferences and pre-fill the login screen the next time the user launches the application.

open login screen when loading app

I have a like,share,win app on my website.
watch example on:
https://www.facebook.com/ExpertLemmer/app_358973127531240
The problem is when you click like, and your not logged in, FB opens the login screen, after login in it re-directs to my usual FB fanpage and not to the next app page. When already logged in it works like it should.
Is there a way to force people to log in when the first page is opened?

GWT - Refresh page Issues when I clicked on Broswers Refresh/reload button

When I am login in GWT Application, it will open my dashboard but when I am click on browsers refresh/reload button it will call entry point of my application and it will load my login page.
So how can I stop this issue.
How can I stay at same page when I am click on Browsers refresh button?
You can save user info in session after logging in and check it in your entry point class before calling login form/method and than decide to show login form or not.
But I think, the better way is not to write login logic by hands, but to integrate spring-security to your gwt application. It will do all logic by itself, you need only to create login page (you can write login page not in gwt) and make it work with gwt.
Spend week if needed to understand how it works and you will have no problems in future.

Just-in-time invocation of Facebook login window from UIWebView

I have an app that presents a UIWebView pointing to my own server. I have a Facebook Like button on some pages inside the UIWebView.
I have it working now, but the login screen is way too big for the phone screen. I would like to present a nicer login dialog such as the one in the Facebook iPhone API, and then continue back to the web view.
The Facebook iPhone SDK has support for a login button and iPhone-friendly login screen, but it assumes that a user will click a login button before doing anything Facebook related. I would like the Like button to just appear, and to bring up the iPhone login screen only when necessary.
I have monitored HTTP requests from my web view, and it looks like I could intercept the login request there, and present the login dialog. However, it seems that this would be fragile, because if Facebook changes those calls then my app will no longer work. Is there a more elegant way to do this?