Updates and example:
What this does:
Creates a simple random generated number to use as a session, called “sessionID”
We then use this on each “message” call to the app, validating parameter3 on the users mobile device against the current sessionID variable in the Kiosk.
I also have a “popup” window if anyone touches the screen, it displays an overlay, yells (politely) at them to not touch the screen, and then disappears.
Scene Structure > Intro
Trigger and actions: on Has been entered:
- generate number - Random Number Generator
- clear - Global Variable sessionID
- clear Text Manipulation Session Info
- concatenate Text Manipulation Session Info - Session ID:
- concatenate Text Manipulation Session Info - value from Random Number Generator
- set text Intuiface-SessionID
timer has elapsed 4 sec:
simulate a tap > OK
Scene Structure > Layer 1 > Group-Configuration > OK
Trigger and actions: is released:
TODO: the issue still with the QR code generator not updating to the new sessionID, meaning the shortURL/QR code are still showing the last link generated.
I notice triggers and actions added to the ON button are overridden by the QR Generator after a few seconds… =(
Initial setup:
I removed API key from being input, and trigger an automatic button press.
Values that need adding:
Interface Assets > Value operators > Api Key: Add your API key
Interface Assets > Value operators > Text Manipulation URL Builder Original text: https://link-to-yourwebsite.com/?apikey={apikey}&deviceid={deviceID}&sessionid={sessionID}
Update to webflowMobile.js:
I simply added the variable “sessionID” and include this via parameter3 in the get & send functions
(my script actually destroys the current jquery session, but that includes a cookie plugin, so for simplicity, i haven’t included).
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
var rootPath = "https://api.intuiface.com/webTriggers/v1/sendMessage"
$(document).ready(function() {
//parse window location to retrieve apikey & device id
var params = getJsonFromUrl();
var apikey = params["apikey"];
var deviceID = params["deviceid"];
var sessionID = params["sessionid"];
//parse all buttons to add onclick functions with proper url
$( ".webtrigger-button" ).each(function() {
this.onclick= function() {
var url = rootPath+"?apikey="+apikey+"&playerDeviceIDs="+deviceID+"¶meter3="+sessionID+"&message="+this.getAttribute("message");
//parse potential parameters
if (this.getAttribute("parameter1") != undefined)
url += "¶meter1="+this.getAttribute("parameter1");
if (this.getAttribute("parameter2") != undefined)
url += "¶meter2="+this.getAttribute("parameter2");
if (this.getAttribute("parameter3") != undefined)
url += "¶meter3="+this.getAttribute("parameter3");
//DEBUG only: to display the request before being sent
//$('#request').html(url);
var res = httpGet(url);
//DEBUG only: to display the reponse
//$('#response').html(res);
};
});
//send initialization message
var initUrl = rootPath+"?apikey="+apikey+"&playerDeviceIDs="+deviceID+"&message=init¶meter3="+sessionID;
httpGet(initUrl);
});
function getJsonFromUrl() {
var query = location.search.substr(1);
var result = {};
query.split("&").forEach(function(part) {
var item = part.split("=");
result[item[0]] = decodeURIComponent(item[1]);
});
return result;
}
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
</script>
I’ll work on it over the next few nights after work, but in the meantime, if you want to take a look:
I couldn’t upload here (15mb, so have added to my OneDrive here)
https://drive.google.com/open?id=1xSKYVkSqg53We6Nj2zTad7shF7fN_LwC