Detect when OnResume is called as a result of closing permission dialog - xamarin.forms

I'm refreshing a screen when OnResume is raised. The intention is to automatically refresh when a user re-opens the app when they've been away doing something else. However, it's firing merely when a permissions dialog is closed - e.g. when the app asks to send notifications. This isn't good because the refresh wipes any changes made by the user.
Is it possible to only handle OnResume when app is opened from being properly backgrounded?

Related

How to handle firebase authentication on vue

I’m working with a vuejs project and I’m using firebase oauth authentication.
I’ve already implemented the sign in with popup flow, and the auth state change event listener, it works pretty well.
The thing is, after I sign in, when I refresh/first load the application, as the auth session persists, there’s a time span between the app load and the auth state change is triggered, so even though I’m logged in, I see the login screen for a few seconds before the event is fired and I get redirected to the main page
For example
I open the application
As I’m not authenticated, I get redirected to /login
I see the login screen
I sign in using the google provider and the popup
I get redirected to the main page /
I refresh the page
I get redirected to /login
As I was already authenticated, the authStateChange event fires and I get redirected to the main page, but this happens after a couple seconds
There’s any way to handle that previous state to be able to show a “loading...” or something? I’ve been reading the docs but the only thing I found is using the event listener that I’m already using
Thank y’all in advance!
Okay y’all, this is the solution I came with:
There’s no way to know if an user will ve logged in until it gets actually logged in and the authStateChange event fires. So the best I could do is, when the user logs in into the application, I store a “EXPECT_LOGIN” value in localStorage, so if I reload the app, and that value it’s true i show a “Loggin in” message with a timeout of, say, 5 seconds. Here we have two possibilities:
The event is fired and the user is logged in automatically
The timeout is fulfilled and I set the “EXPECT_LOGIN” value to False, then I let the user login manually

Firebase .info/connected make false programatically

I am using .info/connected for presence system in my chat app, I want disconnect .info/connected once user logout from app so he will not see online anymore.
(As after logout app will go to login page i.e app still in foreground and .info/connected is returning true)
Presence system working perfectly when app close,but I want to change status to offline once user logout.
If you want to programmatically control the connection state of the app yourself, you can call goOffline and goOnline from your code. Going offline will close the connection that the client keeps to the Firebase backend, which in turns will make .info/connected become false.

Meteor: clicking the link from Accounts.sendResetPasswordEmail

Accounts.forgotPassword() triggers Accounts.sendResetPasswordEmail() and the email is successfully sent. But when I click on the link in the email, a new instance of my app (new browser window) is brought up. How can I prevent that from happening? I want to stay in the calling app, not open another instance of it.

Firebase multiple browser tab authenticate

I am using angularFireAuth and angularFireAuth provides a logged in user variables. Let say $scope.user.id and I use this to verify if the current user logged. And also I use angularFireAuth.logout() to logout user.
Everything work fine on a single open browser tab.
But it doesn't work on multiple tabs.
Login 1 of the tab WILL NOT login the other tabs and set the logged-in variables
Logout 1 of the tab DOES NOT clear the other tabs variables and logout.
So it means
I opened 2 tabs, I call it tab A and tab B. When I logout or login in tab A.
Tab B will not do neither. In the sametime, if I submit something required authenticated in tab b (which tab A already logged out). I still able to submit. (unless I manually do refresh).
If you refresh the browser when you return to the second tab the authentication stored in local storage should update.
You can also leverage the local storage event to share events with other tabs and windows on the same domain. In the case of firebase, the user should automatically be updated within local storage, and kick off an event.
Listen for the storage change event then use firebase getAuth or the API that calls getAuth in angularFireAuth.
Could look like:
function onStorageEvent(storageEvent){
var authData = ref.getAuth();
if (authData !== null) {
// you're logged in
}
}
To be safe a messaging protocol that allows you to specify the action or event that should be handled can be implimented to use the local storage (You will recieve an event everytime storage state changes, ensure to have a message field in storage you can update and only complete actions on the other tabs based on events that update that message array, more safety should be involved here as well).
Shared storage messaging should only be required in case user was previously logged out, and it is intended that, all browser tabs open should change to logged in state when the login is completed in a different tab. Once logged in, all firebase events over websocket recieved by TabA should also be recieved by TabB, so that intertab communication would not be required.

Session Time Out

I am developing a web site using ASP.Net 3.5 C#. I am listing all the Online users ( users who re logged in on my site) in my site. I want to track and update user's status in Database when a user has logged out or simply closed the browser or navigated to some other site. In all these cases I want to update user's status as "Logged Out".
How can i move forward with it.
Thanks
Vivek
When the user clicks the button, you can just handle the click event on the server-side (in code-behind) and then log the status change.
For the case where the browser is closed, you can handle the Session_End event in the global.asax, which fires when the session ends:
public void Session_End(object sender, EventArgs e)
{
// Fires when the session ends
}
Legitimate logout (i.e. Logout by clicking on logout button etc.) can be tracked easily. You just have to handle the event and mark their database status logged out.
However closing the browser is one thing I never had a good success with. You will get many solutions over web which would tell you to capture the close button and then ajax request etc, but I did not have success with any one with that.
(Things like Session_End may come handy but there is a Gotcha that thisevent does not get fired, if you are using anything other than IN-PROC session mode so that's not reliable).
You don't really know if the user has closed the browser or not, or if he navigated to another site. I think you need to use some sort of AJAX control that would send some messages to the server in a given time interval to make sure the user is viewing your site.
First check my answer in this other question:
session Handling in asp.net
You wouldn't be able to immediately close a session and track this change if some user closes the browser, shutdowns computer or something like that. This is achieved by playing with session timeout.
Another possibility could be consider an user online if it triggered some operation against the server in some time interval, thing that'll be implemented in your server logic.
Logging out should be easly trackable because it's an "human user" action. Just implement a "UserLogout" event in your authentication manager class or any other class handling authentication and track logouts there.
Client-side user actions like browsing to another page or closing Web browser can't be tracked because technology limitations: API lacks in this area. It's more because of Web paradigm and its principles. You'll need to miss that.

Resources