{"_id":"56d1f33900a2a70b00b365a5","parentDoc":null,"project":"5526c95cf69851170038b48f","user":"5526ca4cf69851170038b496","__v":0,"version":{"_id":"56d1f33700a2a70b00b3658e","project":"5526c95cf69851170038b48f","__v":2,"createdAt":"2016-02-27T19:04:23.946Z","releaseDate":"2016-02-27T19:04:23.946Z","categories":["56d1f33900a2a70b00b3658f","56d1f33900a2a70b00b36590","56d1f33900a2a70b00b36591","56d1f33900a2a70b00b36592","56d1f33900a2a70b00b36593","56d1f33900a2a70b00b36594","56d1f33900a2a70b00b36595","56d1f33900a2a70b00b36596","56d1f33900a2a70b00b36597","56d1f33900a2a70b00b36598","56d1f33900a2a70b00b36599","56d1f33900a2a70b00b3659a","571f9497ada30c34003b7cee"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"beta","version_clean":"2.0.0-beta","version":"2.0.0-beta"},"category":{"_id":"56d1f33900a2a70b00b36594","pages":["56d1f33900a2a70b00b3659b","56d1f33900a2a70b00b3659c","56d1f33900a2a70b00b3659d","56d1f33900a2a70b00b3659e","56d1f33900a2a70b00b3659f","56d1f33900a2a70b00b365a0","56d1f33900a2a70b00b365a1","56d1f33900a2a70b00b365a2","56d1f33900a2a70b00b365a3","56d1f33900a2a70b00b365a4","56d1f33900a2a70b00b365a5","56d1f33900a2a70b00b365a6","56d1f33900a2a70b00b365a7","56d1f33900a2a70b00b365a8","56d1f33900a2a70b00b365a9"],"__v":1,"project":"5526c95cf69851170038b48f","version":"56d1f33700a2a70b00b3658e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-10T15:43:37.809Z","from_sync":false,"order":4,"slug":"ionic-deploy","title":"Ionic Deploy"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-24T15:07:21.259Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ntUDJ6kiQnS7H6aD8BBY_deploy-diagram-2.png\",\n        \"deploy-diagram-2.png\",\n        \"1248\",\n        \"1128\",\n        \"#925ddf\",\n        \"\"\n      ],\n      \"caption\": \"The deploy service makes it easy to watch for, and react to new updates in your app.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Watching for updates\"\n}\n[/block]\nThere are two ways to watch for updates: continuously, or on-demand. \n\nTo watch continuously, use the `watch()` function:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var deploy = new Ionic.Deploy();\\ndeploy.watch().then(function() {}, function() {},\\nfunction(hasUpdate) {\\n  // Handle response\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"Note: the two empty functions above are required, since the `watch()` method works on the `notify()` feature of the promise.\"\n}\n[/block]\n\nTo check on-demand, call `deploy.check()`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var deploy = new Ionic.Deploy();\\ndeploy.check().then(function(hasUpdate) {\\n      $rootScope.lastChecked = new Date();\\n      $scope.hasUpdate = hasUpdate;\\n    }, function(err) {\\n      console.error('Unable to check for updates:', err);\\n    });\\n\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n## Full manual mode\n\nTo control the complete app update cycle, use the following code snippet that checks for updates, downloads, extracts, and then loads the new version. `deploy.check()` will check for new updates and allow you to then download/extract the latest version.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var deploy = new Ionic.Deploy();\\n\\n// Check for updates\\ndeploy.check().then(function(response) {\\n  // response will be true/false\\n  if (response) {\\n    // Download the updates\\n    deploy.download().then(function() {\\n      // Extract the updates\\n      deploy.extract().then(function() {\\n        // Load the updated version\\n        deploy.load();\\n      }, function(error) {\\n        // Error extracting\\n      }, function(progress) {\\n        // Do something with the zip extraction progress\\n        console.log(progress);\\n      });\\n    }, function(error) {\\n      // Error downloading the updates\\n    }, function(progress) {\\n      // Do something with the download progress\\n      console.log(progress);\\n    });\\n  }\\n}, function(error) {\\n  // Error checking for updates\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Pulling updates from deploy channels\"\n}\n[/block]\nIn order to pull updates from a specific channel you will need to set the channel using `deploy.setChannel()`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var deploy = new Ionic.Deploy();\\ndeploy.setChannel(\\\"customtag\\\");\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nIn the above example, updates will pull from the deploy channel with the tag `customtag`. You can learn more in the [Deploy Channels](doc:deploy-channels) guide.","excerpt":"Update apps within your code","slug":"deploy-updating-apps","type":"basic","title":"Updating Apps"}

Updating Apps

Update apps within your code

[block:image] { "images": [ { "image": [ "https://files.readme.io/ntUDJ6kiQnS7H6aD8BBY_deploy-diagram-2.png", "deploy-diagram-2.png", "1248", "1128", "#925ddf", "" ], "caption": "The deploy service makes it easy to watch for, and react to new updates in your app." } ] } [/block] [block:api-header] { "type": "basic", "title": "Watching for updates" } [/block] There are two ways to watch for updates: continuously, or on-demand. To watch continuously, use the `watch()` function: [block:code] { "codes": [ { "code": "var deploy = new Ionic.Deploy();\ndeploy.watch().then(function() {}, function() {},\nfunction(hasUpdate) {\n // Handle response\n});", "language": "javascript" } ] } [/block] [block:callout] { "type": "warning", "body": "Note: the two empty functions above are required, since the `watch()` method works on the `notify()` feature of the promise." } [/block] To check on-demand, call `deploy.check()`: [block:code] { "codes": [ { "code": "var deploy = new Ionic.Deploy();\ndeploy.check().then(function(hasUpdate) {\n $rootScope.lastChecked = new Date();\n $scope.hasUpdate = hasUpdate;\n }, function(err) {\n console.error('Unable to check for updates:', err);\n });\n", "language": "javascript" } ] } [/block] ## Full manual mode To control the complete app update cycle, use the following code snippet that checks for updates, downloads, extracts, and then loads the new version. `deploy.check()` will check for new updates and allow you to then download/extract the latest version. [block:code] { "codes": [ { "code": "var deploy = new Ionic.Deploy();\n\n// Check for updates\ndeploy.check().then(function(response) {\n // response will be true/false\n if (response) {\n // Download the updates\n deploy.download().then(function() {\n // Extract the updates\n deploy.extract().then(function() {\n // Load the updated version\n deploy.load();\n }, function(error) {\n // Error extracting\n }, function(progress) {\n // Do something with the zip extraction progress\n console.log(progress);\n });\n }, function(error) {\n // Error downloading the updates\n }, function(progress) {\n // Do something with the download progress\n console.log(progress);\n });\n }\n}, function(error) {\n // Error checking for updates\n});", "language": "javascript" } ] } [/block] [block:api-header] { "type": "basic", "title": "Pulling updates from deploy channels" } [/block] In order to pull updates from a specific channel you will need to set the channel using `deploy.setChannel()`: [block:code] { "codes": [ { "code": "var deploy = new Ionic.Deploy();\ndeploy.setChannel(\"customtag\");", "language": "javascript" } ] } [/block] In the above example, updates will pull from the deploy channel with the tag `customtag`. You can learn more in the [Deploy Channels](doc:deploy-channels) guide.