1. Home
  2. SureFox iOS Javascript API

SureFox iOS Javascript API

KB ID: 42G2103712
Views: 105
Updated: May 2021

SureFox iOS now comes with a built-in set of Javascript APIs. Embed them in your web application to perform variety of actions such as refreshing the page or resetting SureFox Idle Timer.

In order to use these methods, make changes in your web page by making functions as below.

window.location = “sfcallback:reload”

List of methods available:

MethodSyntaxDescription
reloadsfcallback:reloadReloads current page
homesfcallback:homeGo to Home or Run at startup page
resetSureFoxIdleTimersfcallback:resetSureFoxIdleTimerResets the Idle Timer of SureFox
getuuidsfcallback:getuuid:printuuidGet Device Unique ID

Examples:

  • Reload Current WebPage onClick():
<html>
<head>
<style type=”text/css”>
</<style>
<script type=”text/javascript”>
function refreshNow()
{
window.location = “sfcallback:reload”;
}
</script>
</head>
<body>
<div >
<span style=”width:116px;margin-bottom:10px;”
onclick=”refreshNow()”>Refresh Now</span>
</div>
</body>
</html>
  • Go to Home Page / Home Screen onClick():
<html>
<head>
<script type=”text/javascript”>
function goHome()
{
window.location = “sfcallback:home”;
}
</script>
</head>
<body>
<div >
<span style=”width:116px;margin-bottom:10px;”
onclick=“goHome()”>Go Home</span>
</div>
</body>
</html>
  • Reset SureFox IdleTimer: In the example, on page load, a timer starts which calls resetSureFoxIdleTimer after the given time interval. If the SureFox IdleTimeout value is more than the interval, this script will cancel SureFox Idle Timer.
<html>
<head>
<script type=“text/javascript”>
function resetSureFoxIdleTimer()
{
window.location = “sfcallback:resetSureFoxIdleTimer”;
}
var count = 30;
function autoResetIdleTimer(){
setInterval(function(){
if(count==0){
resetSureFoxIdleTimer();
count = 30;
}
count–;
},1000);
}
</script>
</head>
<body onload=“autoResetIdleTimer()”>
</body>
</html>

Get Unique Device ID: Once the function printuuid mentioned below gets implemented, we can do anything with the UUID. In our example, we have done an alert. Give any function name like printuuid, printUUID, print1, etc. however not name the function as Print (it will call the print function of the browser).

<html>
<head>
<script type=”text/javascript”>
function getUUID()
{
window.location=”sfcallback:getuuid:print1″;
}
function print1(uuid)
{
alert(uuid);
}
</script>
</head>
<body>
<button onclick=”getUUID()” style=’width:50px;height:50px;’/>
</body>
</html>

For more details on our products, click here 
If you need further assistance, please submit a ticket here