Skip to content

Instantly share code, notes, and snippets.

@Gurpartap
Created August 7, 2011 04:49
Show Gist options
  • Save Gurpartap/1130056 to your computer and use it in GitHub Desktop.
Save Gurpartap/1130056 to your computer and use it in GitHub Desktop.
Compare iOS app version with latest version from server
<?php
$request_body = @file_get_contents('php://input');
$request_data = json_decode($request_body, true);
$bundle_version = $_GET['bundleVersion'];
$latest_version = "1.0.1";
if (version_compare($bundle_version, $latest_version, '<')) {
$result = array(
'needsUpdate' => TRUE,
'latestVersion' => $latest_version
);
}
else {
$result = array(
'needsUpdate' => FALSE,
'latestVersion' => $latest_version
);
}
header('Content-Type: application/download');
exit (json_encode($result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment