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.
Purpose
The purpose of this knowledge article is to provide a guide on how to use the Javascript API for SureFox iOS.
Prerequisites
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:
Method | Syntax | Description |
reload | sfcallback:reload | Reloads current page |
home | sfcallback:home | Go to Home or Run at startup page |
resetSureFoxIdleTimer | sfcallback:resetSureFoxIdleTimer | Resets the Idle Timer of SureFox |
getuuid | sfcallback:getuuid:printuuid | Get Device Unique ID |
Steps
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>
Need help?
Was this helpful?
YesNo