WinRT - How to Enable "Timed Logout" Feature in Webview or Detect Pointer Pressed/Tapping Event in Webview - webview

I am developing a WinRT app. One of the requirements is that the app should have a "timed logout" feature. What this means is that on any screen, if the app has been idle for 10 mins, the app should logout and navigate back to the home screen.
By using this link and applied the logic given in below link
https://stackoverflow.com/a/18878954/3560390
Its works fine in all screens except webview,because webview not supports any touch event or tap event.
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.aspx
How to enable "timed logout" feature in WinRT webview ?
Any help is welcome..
Thanks!

Unfortunately, this limitation hasn't been fixed with the improvements to the WebView in Windows 10.
Here are 2 things you can try:
1) When the user navigates to the page, begin your 10 minute timer. After 10 minutes, display a modal dialog with an "OK" button which says something like "Click to continue browsing...". The user then has 10 seconds (or whatever you choose) to click OK. If not, then navigate back to the home screen.
2) The WebView does have working GotFocus and LostFocus events. Perhaps you can use these methods to restart your 10 minute timer.
An Idea
If your WebView is loading content with ms-appx-web, ms-local-stream, or https content (which would require a content URI rule in your appxmanifest) OR if you are using NavigateToString, then you may be able to do something like this:
private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
MyWebView.InvokeScript("eval", new[]
{
"document.addEventListener('mousemove', function(){window.external.notify('MouseMove');});"
});
}
private void MyWebView_ScriptNotify(object sender, NotifyEventArgs e)
{
if( e.Value == "MouseMove" )
{
// Restart timer
}
}

Related

How to stop AppOpenAd showing multiple times? (Unity)

I have implemented AppOpenAds from Admob, they work as intended...To a point.
Unfortunately, when the viewer is watching a 'rewarded' video (ie to get coins in-game) after it finishes, it then shows an AppOpenAd, as it obviously thinks the user has left the app (when they have just watched a video instead). So they are getting a double-whammy ad!
Is there any way I can stop this?
It's using this;
private void OnAppStateChanged(AppState state)
{
// Display the app open ad when the app is foregrounded.
UnityEngine.Debug.Log("App State is " + state);
if (state == AppState.Foreground)
{
AppOpenAdManager.Instance.ShowAdIfAvailable();
}
}
Edit - just to clarify - Rewarded ads work, they just then show an AppOpenAd when the rewarded ad finishes due to it thinking I was outside of the app.

Xamarin UI test fail to identify System dialog(s) of iOS App

I want to automate our iOS app using xamarin UI test. To access the app, user has to give his/her TouchID. But both Xamarin Test recorder and Repl() failed to identify the Touch ID system dialog (Please see attached screenshot).
This dialog is not developed by our developers and it is a system dialog.
How do I perform the action(s) which associated with this Touch ID?
Thanks
System dialogs is not something you can query with calabash or Xamarin.UITest, which is super annoying.
You would need to use a backdoor to simulate a success or fail state for this. You can read more about these here:
https://developer.xamarin.com/guides/testcloud/uitest/working-with/backdoors/
Basically you define a method in your AppDelegate:
[Export("touchIdBackdoor:")] // notice the colon at the end of the method name
public NSString TouchIdBackdoor(NSString value)
{
if (value == "true")
{
//simulate ok finger press
}
else
{
//simulate failed finger
}
}
Then in your test, when you expect the touch id to appear, you invoke the backdoor:
app.Invoke("touchIdBackdoor:", "true");
To dismiss the touch id and set whatever you need to continue.

IIOS IPAD No Unload,beforeunloador, paghide events

I have a MVC web database application where the records are basically documents with items.
Documents are locked, not items and they locked by code when the user looks in any of 4 or 5 different screens for any given document.
there is a 10 minute time out on the record locks. The user does not do anything with the record for 10 minutes and another can take the record. There is code that detects the lock was lost and taken by someone else. It works fine and is technically sound.
The workflow of the application relies on the lock being released when the user leaves the screen or closes the browser, or if they press the refresh button.
These are work fine on windows and android but not on ipad.
I understand there is no
beforeunload
on ios but I though there was
unload
or
pageHide
neither of these work.
Here is my code.
var isOnIOS = navigator.userAgent.match(/iPad/i)||
navigator.userAgent.match(/iPhone/i); var eventName = isOnIOS ?
"pageHide" : "beforeunload";
window.addEventListener(eventName, function (event) {
ReleaseRecordLock(); } );
This code works on all mentioned platforms except that the events don't fire on IOS.
It looks to me that this is deliberate on Apple's part so I an not thinking it will change.
So now the question.
What can I do to ensure that these records get unlocked if a user changes screens or closes the browser. If they don't no users will be able to access the document for 10 minutes which will not be acceptable.
Thanks
Edit... I don't need pop ups or notification. I just need reliable unlocking
As mentioned above none of the events that are supposed to work actually fire. pageHide and unload do nothing.
I found mentions of how to get around this problem but no details so I though I would detail it here.
This solutions works with areas and standard sites.
My solution to get around part of this was to detect if the browser is running on IOS and if so to change the link in the menu.
<li>
#{
if(Request.UserAgent.Contains("iPad") || Request.UserAgent.Contains("iPhone"))
{
<a onclick="IOSReleaseLock('controller', 'action')" href="javascript:void(0);">LinkText</a>
}
else
{
#Html.ActionLink("link Text","action","controller",new { Area = "Tasks" },null);
}
}
</li>
Every single link in the application has to have a function called IOSReleaseLock() available or the solution will not work. Not all pages lock records, only those that actually change documents. Reports, and basic website functions such as change password, log out, and the sys admin stuff do not need record locks.
At this point I have 2 versions of IOSReleaseLock()
This is the version that is used on pages that do not required unlocking.
function IOSReleaseLock(_controller, _action)
{
var url = '/__controller__/__action__/';
url = url.replace('__controller__', _controller);
url = url.replace('__action__', _action);
window.location.href = url;
}
This is the version that is placed on pages that required unlocking.
function IOSReleaseLock(_controller, _action )
{
var url = '/__controller__/__action__/';
url = url.replace('__controller__', _controller);
url = url.replace('__action__', _action);
UnloadingRecordLockRelease();
window.location.href = url;
}
Every link has a wrapper so every single page must load a version of IOSReleaseLock(). This includes your /home/index or where ever your application starts. If you miss one then once you are on that page your menu system links will not work anymore.
Pages that require the UnloadingRecordLockRelease() function load that version and the pages that do not require unlocking load the first version.
On IOS every time you click a link, IOSReleaseLock() is called. This may seem to be obvious, but for clarity, the version of IOSReleaseLock() that executes is the version that is on the current page, not the version on the page you are going to.
So as long as the user stays on the site and does not close the browser then the records are unlocked correctly.
When the user logs out all records are unlocked but I have no solution for when the browser tab is closed or when the browser is closed without the user logging out.

Adobe Air Application - Not in background and not in Foreground - iPhone

I have an adobe air application - AS3 for iOs and Android.
Whenever the user clicks the home button, and thus the application is now in the background, the application automatically stops, which is the expected behavior. Now, if the user is in the application, and he double clicks his home button, showing all the multiple windows, the application continues running, which is not what i want. How can i access that state ( Not Background, not foreground )? If i can access it, i would then put my pausing code into that state, but how can i access that particular state?
When the user clicks the home button the app is moved to the background and suspended. The app isn't closed. The OS can close the app to free memory. If your app is a memory hog you'll see this happening.
You use events dispatched by the NativeApplication object. Below is example code to listen and handle these events.
import flash.events.Event;
import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;
// create listeners to NativeApplication
private var naApplication: NativeApplication;
naApplication = NativeApplication.nativeApplication;
naApplication.addEventListener(Event.ACTIVATE, eActivate);
naApplication.addEventListener(Event.DEACTIVATE, eDeactivate);
naApplication.addEventListener(Event.EXITING, eExiting);
private function eActivate(e: Event): void {
// app has opened or resumed
application.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}
private function eDeactivate(e: Event): void {
// app is going to be moved to background
application.systemIdleMode = SystemIdleMode.NORMAL;
}
private function eExiting(e: Event): void {
// app is going to be closed by user or by the OS (usually to free up memory)
// do whatever exit code here then remove all listeners (to be clean don't rely on OS to close them)
application.removeEventListener(Event.ACTIVATE, eActivate);
application.removeEventListener(Event.DEACTIVATE, eDeactivate);
application.removeEventListener(Event.EXITING, eExiting);
application.systemIdleMode = SystemIdleMode.NORMAL;
removeEventListener(Event.ENTER_FRAME, eMainTimer);
}
The systemIdleMode and ENTER_FRAME are just examples of typical code. Let me know of any questions.

How to detect user idle time since last touch and return the app to home page using phonegap

I would like to check for the user idle time since last touch and return the app to the home page after some period of time. I want this to be done using phonegap.
I googled and did find few solutions but I want to detect the idle time and return the app to the home page.
Thanks.
Using jQuery you *could bind a start touch event and end touch event then using a timer to execute a function
$('body').bind('touchstart',function() {
clearInterval(myTimer);
});
$('body').bind('touchend', function() {
myTimer = setInterval(function() {
/* return user to homepage */
},30000);
});
Touch events are a little buggy in mobile devices. But you set an Interval timer to run after a set amount of time after the last touch is detected. Remembering to clear it on the next touchstart event. Its a bit messy but should work (I havent tested it btw)
I got this working by setTimeout('Redirect()', 10000); where Redirect fn is function Redirect() { window.location.href="mylink.html"; }

Resources