e-mission / cordova-jwt-auth

BSD 3-Clause "New" or "Revised" License
2 stars 9 forks source link

Notification "Please login to continue server communication" generated before signing in #14

Closed shankari closed 7 years ago

shankari commented 7 years ago

The cordova-jwt-auth plugin is currently launched on startup. In general, we want to continue doing this because as part of startup, we attempt to get a valid auth token, so subsequent server calls are faster since they don't have to wait for the token.

We also check to see if the auth is successful at startup - it is not, we prompt to re-login. This should avoid the issues with auth that we had earlier on iOS.

BUT this leads to a problem during install. When the app is first launched, we haven't logged, so auth is unsuccessful. So we generate the prompt, which is displayed after the user has logged in, which is super confusing.

What we really want to do is to only generate the notification after the onboarding is complete.

shankari commented 7 years ago

Obvious solution is to store the state of when the onboarding is complete and only generate the notification if it is. But the problem is where to store it. Obvious solution is to store in the usercache, but we currently don't have a dependency between auth and usercache and I am not sure I want to introduce one.

Another option is to move the check to javascript, in which case there is no dependency. The problem with that is that it is not clear when the javascript code will be invoked on android because the activity doesn't run all the time, only when it is launched, and the user may go for a long time without launching.

shankari commented 7 years ago

Final option is to not do the check in the init code at all, but as part of a "periodic checks" module that runs at the start and end of every trip or periodically or sth. We already do consent checking there, why not add sign in checking?

shankari commented 7 years ago

Also, we may try to run the activity invisibly in the background using something like https://github.com/katzer/cordova-plugin-background-mode or https://github.com/MobileChromeApps/cordova-plugin-background-app

in which case the "periodic checks" can be in javascript.

shankari commented 7 years ago

so the clear winner is a "periodic checks" module, either in native code or in javascript.

shankari commented 7 years ago

that restructuring is too much work though. Let's add the dependency for now and restructure later.

shankari commented 7 years ago

Done. Closing issue.