Evening,
I'm trying to implement a global activity timeout feature to auto log users out of my application after a predetermined amount of time. I've gone through a couple of different implementations but seem to get stuck on something each time. My current attempt, following a guide here, is as follows:
AppDelegate.cs
var tapRecognizer = new InteractionGestureRecognizer { CancelsTouchesInView = false };
this.window.AddGestureRecognizer(tapRecognizer);
InteractionGestureRecognizer.cs:
class InteractionGestureRecognizer : UITapGestureRecognizer
{
public override void TouchesBegan(NSSet touches, UIEvent evt)
{
Debug.WriteLine("TouchesBegan: " + touches);
base.TouchesBegan(touches, evt);
}
public override void TouchesMoved(NSSet touches, UIEvent evt)
{
Debug.WriteLine("TouchesMoved: " + touches);
base.TouchesMoved(touches, evt);
}
public override void TouchesEnded(NSSet touches, UIEvent evt)
{
Debug.WriteLine("TouchesEnded: " + touches);
base.TouchesEnded(touches, evt);
}
public override void TouchesCancelled(NSSet touches, UIEvent evt)
{
Debug.WriteLine("TouchesCancelled: " + touches);
base.TouchesCancelled(touches, evt);
}
}
I'm getting absolutely no debug lines, and touches to my app don't reach any subviews so tapping a field doesn't pop up a keyboard etc.
Other things I've tried are:
In shared code, looping through the children of the
StackLayout
and attaching aFocused
,Clicked
orTapped
event to each element, but this didn't capture touches on the background or scrolls on a table viewA standard, non sub classed,
UITapGestureRecognizer
withNumberOfTaps
set to 1 applied directly to the UIWindow but this seemed to stop any taps on aListView
Probably something else but I've forgotten now!
Can anyone notice an obvious mistake or guide me to a way to implement a feature like this?
Thanks in advance