{"id":2535,"date":"2018-01-12T04:03:29","date_gmt":"2018-01-11T20:03:29","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vsappcenter\/?p=2535"},"modified":"2019-02-16T15:30:33","modified_gmt":"2019-02-16T22:30:33","slug":"deliver-lightning-fast-updates-to-your-users-with-codepush-a-beginners-guide","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/appcenter\/deliver-lightning-fast-updates-to-your-users-with-codepush-a-beginners-guide\/","title":{"rendered":"Deliver Lightning Fast Updates to your Users with CodePush: A Beginner\u2019s Guide"},"content":{"rendered":"<p>As app developers, we move fast, whether we&#8217;re working on code, testing, validating, shipping, or iterating.   <\/p>\n<p>Delivering critical bug fixes and minor features to your users <em>quickly<\/em> means the difference between a great user experience and a lackluster one, or, put more simply, the difference between a happy user and one who deletes your app. Bugs and errors are unavoidable elements of programming that we all know too well. Because of this, updates and patches serve as the crutch of development.  <\/p>\n<p>In mobile development, though, updates and patches aren\u2019t immediate. You spend time re-building and re-packaging for public app stores, and then the 24&ndash;48 hour average review times feel like a lifetime, especially in cases where the update is critical to your app\u2019s performance.  <\/p>\n<p><strong>CodePush, <a href=\"https:\/\/microsoft.github.io\/code-push\/articles\/CodePushOnMobileCenter.html\" rel=\"noopener\" target=\"_blank\"><strong>which was integrated into Visual Studio App Center last year<\/strong><\/a>, solves this problem by allowing React Native (and Cordova) developers to publish and deploy app updates directly to users.<\/strong> CodePush simplifies the app update process, eliminating app submission and approval wait times. It acts as a central repository, making it easy to publish asset tweaks and changes that don\u2019t require you to build a binary, such as JavaScript, HTML, CSS.  <\/p>\n<p>Thousands of developers use CodePush to deliver awesome apps. To help you get started, I\u2019ll walk through one of the most common CodePush scenarios, over-the-air updates.   <\/p>\n<p><img decoding=\"async\" src=\"\" alt=\"\" width=\"1024\" height=\"363\" class=\"aligncenter size-large wp-image-2545\" \/><\/p>\n<h2>Configuring Pre-Requisites Before You Start<\/h2>\n<p>To use all of the App Center CodePush features, complete a few simple steps:   <\/p>\n<ol>\n<li><a href=\"https:\/\/appcenter.ms\/login\" rel=\"noopener\" target=\"_blank\">Log in<\/a> or <a href=\"https:\/\/appcenter.ms\/create-account\" rel=\"noopener\" target=\"_blank\">create<\/a> your free App Center account.<\/li>\n<p>&nbsp;<\/p>\n<li>Install the App Center CLI: \u2018npm install -g appcenter-cli\u2019.\n&nbsp;\nCodePush functionality is primarily used via the CLI, but you can also manage deploys, patch releases, view deployment keys, and more, from your App Center portal.<\/li>\n<p>&nbsp;<\/p>\n<li>\u201c<em>CodePush-ify<\/em>\u201d your app.  \n&nbsp;\nBefore you can use CodePush, you need to add the appropriate SDKs to your app and configure them to query for CodePush updates based on your preferences, including how you\u2019d like to apply your updates.  \n&nbsp;\nThere are only a few steps, outlined in our docs for <a href=\"https:\/\/docs.microsoft.com\/en-us\/appcenter\/distribution\/codepush\/cordova\" rel=\"noopener\" target=\"_blank\">Cordova<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/appcenter\/distribution\/codepush\/react-native\" rel=\"noopener\" target=\"_blank\">React Native<\/a> developers.<\/li>\n<\/ol>\n<p>That\u2019s it! You\u2019re ready to start pushing updates to your users.<\/p>\n<h2>Pushing Your First Update (and Beyond)<\/h2>\n<p>After you finalize and commit your changes to your app\u2019s code and\/or assets, push the update to your Staging deployment environment. When getting started with CodePush, we recommend creating two deployments: <em>Staging<\/em> and <em>Production<\/em>. This allows you to visualize and test any changes before releasing the update to your users.  <\/p>\n<p>In order to release, use the <code>appcenter codepush release-react<\/code> commands in the App Center CLI (or <code>appcenter codepush release-cordova<\/code>, depending on how you\u2019ve built your app). Releases distributed via CodePush are visible in the CLI, as well as the App Center portal.<\/p>\n<p><img decoding=\"async\" src=\"\" alt=\"\" width=\"1024\" height=\"703\" class=\"aligncenter size-large wp-image-2555\" \/><\/p>\n<p>Once you\u2019ve verified that you&#8217;d like to send this update to your users, you can \u201cpromote\u201d the update to your Production deployment environment from Staging. Use the <code>appcenter codepush promote<\/code> command in the CLI, or navigate to the App Center portal, click the release, and press the <em>Promote<\/em> button.  <\/p>\n<p>To verify the promotion worked, check the release history for the Production deployment environment.  <\/p>\n<p><img decoding=\"async\" src=\"\" alt=\"promote screenshot\" width=\"1024\" height=\"753\" class=\"aligncenter size-large wp-image-2605\" \/><\/p>\n<p>Once complete, your users will instantly have access to your update.   <\/p>\n<p>As mentioned earlier, you determine how users receive your updates when you \u201cCodePush-ify\u201d your app, whether it&#8217;s configuring the app to update on start, on resume, or a custom method.  <\/p>\n<p>Just like that, a critical bug, UI issue, or performance problem is no more!  <\/p>\n<h3>Pro Tip<\/h3>\n<p>How &#8220;over-the-air&#8221; updates are defined can vary, but it&#8217;s good to be aware that Apple&#8217;s App Store developer agreement (section 3.3.2) states that releasing bug fixes, improvements, or features that maintain the apps original presented purpose are acceptable over-the-air updates. <\/p>\n<h2>The Case for CodePush: When, Why, and How to Use Over-the-Air Updates<\/h2>\n<p>To better illustrate how CodePush works, here\u2019s a (likely relatable) scenario.  <\/p>\n<h3>The Situation<\/h3>\n<p>You have the hottest up-and-coming app on the market, and your team spent countless hours working on an enormous update that gives your users tons of added functionality. A few weeks ago, your lead developer integrated the CodePush CLI into your app as a safety net and mitigation tactic. He\u2019s occasionally pushed small updates and fixes to your users in an attempt to get the whole team onboard.  <\/p>\n<p>Today is release day. You\u2019ve submitted to the Apple App Store and Google Play, and you\u2019re live. You\u2019ve heavily promoted the new features, so you anticipate that many users will install the latest version in the first 48 hours.   <\/p>\n<h3>The Problem<\/h3>\n<p>To your dismay, a few minutes after your new version\u2019s live, your team discovers a critical bug. Every time a user presses a particular button, the entire app freezes and eventually crashes. Something slipped by your unit and UI tests* and it\u2019s causing your app to crash instantly for a large set of your users.  <\/p>\n<p>*gasp*   <\/p>\n<p>In these scenarios, time is critical. After you identify what\u2019s causing the crash and implement a solution, what do you do?   <\/p>\n<h3>The Solution<\/h3>\n<p><strong>Use CodePush to send the hotfix directly to your users with no resubmission or approval delays.<\/strong><\/p>\n<p>Your marketing push isn\u2019t wasted, since the update automatically appears in the version they\u2019ve installed on their device.   <\/p>\n<p>For a detailed real-world example, <a href=\"https:\/\/blogs.msdn.microsoft.com\/vsappcenter\/guest-blog-fixing-disasters-asap-with-instant-updates\/\" rel=\"noopener\" target=\"_blank\">learn how PocketLeap uses CodePush to fix disasters ASAP<\/a>.  <\/p>\n<p><em>*Automated testing on real devices and detailed crash reporting are a separate topic, but, Visual Studio App Center includes easy-to-use, cloud-hosted Test and Crash services, too.<\/em>  <\/p>\n<h3>Advanced Scenarios<\/h3>\n<p>I\u2019ve highlighted the main example to get you up and running, but CodePush is highly configurable, so you get a lot of \u201cwhen, where, and how\u201d flexibility.   <\/p>\n<p>From manually or automatically <a href=\"https:\/\/docs.microsoft.com\/en-us\/appcenter\/distribution\/codepush\/cli\" rel=\"noopener\" target=\"_blank\">rolling back to prior versions<\/a> to providing an <a href=\"https:\/\/blogs.msdn.microsoft.com\/vsappcenter\/ab-test-all-the-things-react-native-experiments-with-app-center\/\" rel=\"noopener\" target=\"_blank\">A\/B Testing<\/a> framework, CodePush is a simple, yet powerful service for app developers.   <\/p>\n<h2>What\u2019s next for App Center?<\/h2>\n<p>As a team, we\u2019re constantly <a href=\"https:\/\/docs.microsoft.com\/en-us\/appcenter\/general\/roadmap\" rel=\"noopener\" target=\"_blank\">working on new features<\/a>, improving existing functionality, and integrating with other App Center services to simplify app development, fit into existing workflows, and allow developers to ship better code.  <\/p>\n<p><a href=\"https:\/\/appcenter.ms\/signup\" rel=\"noopener\" target=\"_blank\">Log in or create<\/a> your <strong>free<\/strong> App Center account to get started today.\n&nbsp;\n<a href=\"https:\/\/appcenter.ms\/signup\"><img decoding=\"async\" src=\"\" alt=\"Get Started Button\" width=\"300\" class=\"aligncenter\" \/><\/a>\n&nbsp;\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As app developers, we move fast, whether we&#8217;re working on code, testing, validating, shipping, or iterating. Delivering critical bug fixes and minor features to your users quickly means the difference between a great user experience and a lackluster one, or, put more simply, the difference between a happy user and one who deletes your app. [&hellip;]<\/p>\n","protected":false},"author":42,"featured_media":38034,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2535","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mobiledev"],"acf":[],"blog_post_summary":"<p>As app developers, we move fast, whether we&#8217;re working on code, testing, validating, shipping, or iterating. Delivering critical bug fixes and minor features to your users quickly means the difference between a great user experience and a lackluster one, or, put more simply, the difference between a happy user and one who deletes your app. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/posts\/2535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/comments?post=2535"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/posts\/2535\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/media\/38034"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/media?parent=2535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/categories?post=2535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/appcenter\/wp-json\/wp\/v2\/tags?post=2535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}