Skip to main content

Report to Cloud URL

Your application may or may not use a Report to Cloud URL. It the applications main configuration data file is located on a remote server a Report to Cloud URL is required. This means the JSON data in the configuration file will include a dataURL and a reportToCloudURL.

Functions of the Report to Cloud URL​

The primary function of the file found at the Report to Cloud URL is to provide the mobile app with a time-stamp indicating the last time the app's content changed. If the mobile apps finds a different time-stamp than the last time it checked, the user is prompted to "refresh."

The file at the Report to Cloud URL is usually created dynamically with .PHP or another server-side scripting language. It may also be a simple plain-text file. The contents of this file is a time-stamp value that must be updated each time the app's main configuration file changes.

Output Format​

Regardless of whether or not the file is created dynamically using a server-side script or saved as a plain text file, the output is the same.

{
"lastModifiedUTC": "Sat, 04 Jun 2011 06:40:32 -0700"
}

The "lastModifiedUTC" text never changes. The "Sat, 04 Jun 2011 06:40:32 -0700" date value changes when the app's main configuration file changes. The date format is not significant, any format can be used.

Because the text stored is a simple JSON structure it can be viewed in a regular web-browser. This means you should be able to enter the app's Report To Cloud URL in a standard browser and see the JSON data. If you cannot do this with a regular browser your script or file is not working properly.

Report to Cloud and Merge Fields​

Appending merge fields to the Report To Cloud URL allows you to capture device specific information, such as it's unique id, at run-time, everytime the app launches. In this case, your backend script parses the values appended to the end of the URL, inserts the values into a database or other backend storage mechanism, then outputs the time-stamp for the mobile app to consume and save.

Sample URL with Merge Fields​

"reportToCloudURL":"http://www.mysite.com/stats.php?deviceId=[deviceId]&deviceLatitude=[deviceLatitude]&deviceLongitude=[deviceLongitude]

Device Requests: http://www.mysite.com/stats.php?deviceId=88478472938382&deviceLatitude=38.498929&deviceLongitude=-121.2334 (note the merged data in the URL)

A Sample .PHP Script to Save the Values​

<?php

//get the device information from the URL
$deviceId = $_GET['deviceId'];
$deviceLatitude = $_GET['deviceLatitude'];
$deviceLongitude = $_GET['deviceLongitude'];

//query to save device information in database
$sql = "INSERT INTO Stats_Table (deviceId, deviceLatitude, deviceLongitude) ";
$sql .= "VALUES ('" . $deviceId . "', '" . $deviceLatitude . "', '" . $deviceLongitude . "') ";

//execute query here....

//output the app's last modified date in JSON format for the app to consume and save.
echo "{\"lastModifiedUTC\":\"Sat, 04 Jun 2011 06:40:32 -0700\"}";

?>