{"_id":"563274ee49e16d0d001223d7","githubsync":"","user":"561b45c2ab412a0d004d85d6","version":{"_id":"561ae15463ef571900ca68d6","project":"561ae15363ef571900ca68d3","__v":3,"createdAt":"2015-10-11T22:23:16.492Z","releaseDate":"2015-10-11T22:23:16.492Z","categories":["561ae15563ef571900ca68d7","56255c864dcb400d00ff4427","56326faf45f2cb0d006be3f1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":3,"category":{"_id":"56326faf45f2cb0d006be3f1","pages":["563274ee49e16d0d001223d7","56cf38da287eb20b009f9ec1"],"project":"561ae15363ef571900ca68d3","version":"561ae15463ef571900ca68d6","__v":2,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-29T19:12:47.370Z","from_sync":false,"order":1,"slug":"examples","title":"Examples"},"project":"561ae15363ef571900ca68d3","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-29T19:35:10.631Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"With AppHub and React Native it is now possible to seamlessly update your app while users are in the app.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/GSeeqW86T3eCQjSSZbl6_Screenshot%202015-10-29%2015.48.03.png\",\n        \"Screenshot 2015-10-29 15.48.03.png\",\n        \"748\",\n        \"602\",\n        \"#1d3650\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThis example [AppDelegate.m](https://github.com/AppHubPlatform/AppHubStarterProject/blob/master/iOS/AppHubStarterProject/AppDelegate.m) shows how you can prompt your users when you push an AppHub update, and then reload the app on command.\n\n1. When you push an update, users are shown a UIAlertView that prompts them to either \"Update\" or \"Cancel\".\n2. If they press \"Cancel\", the update is applied the next time that they close and open the app.\n3. If they press \"Update\", the app restarts with the new version.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Extending AppHubStarterProject\"\n}\n[/block]\nYou can configure this behavior as you'd like -- feel free to fork or simply copy `AppDelegate.m`. Here are some potential extensions to this project:\n\n1. Instantly updating without prompting the user.\n2. Saving state in `NSUserDefaults` before restarting to avoid interrupting the user's experience.\n3. Updating your app in the background with [background fetch](https://www.objc.io/issues/5-ios7/multitasking/).\n\nUsing AppHub in other cool ways? Let us know at [support:::at:::apphub.io](mailto:support@apphub.io)!","excerpt":"","slug":"example-update-app-during-execution","type":"basic","title":"Update App During Execution"}

Update App During Execution


With AppHub and React Native it is now possible to seamlessly update your app while users are in the app. [block:image] { "images": [ { "image": [ "https://files.readme.io/GSeeqW86T3eCQjSSZbl6_Screenshot%202015-10-29%2015.48.03.png", "Screenshot 2015-10-29 15.48.03.png", "748", "602", "#1d3650", "" ] } ] } [/block] This example [AppDelegate.m](https://github.com/AppHubPlatform/AppHubStarterProject/blob/master/iOS/AppHubStarterProject/AppDelegate.m) shows how you can prompt your users when you push an AppHub update, and then reload the app on command. 1. When you push an update, users are shown a UIAlertView that prompts them to either "Update" or "Cancel". 2. If they press "Cancel", the update is applied the next time that they close and open the app. 3. If they press "Update", the app restarts with the new version. [block:api-header] { "type": "basic", "title": "Extending AppHubStarterProject" } [/block] You can configure this behavior as you'd like -- feel free to fork or simply copy `AppDelegate.m`. Here are some potential extensions to this project: 1. Instantly updating without prompting the user. 2. Saving state in `NSUserDefaults` before restarting to avoid interrupting the user's experience. 3. Updating your app in the background with [background fetch](https://www.objc.io/issues/5-ios7/multitasking/). Using AppHub in other cool ways? Let us know at [support@apphub.io](mailto:support@apphub.io)!