{"action":"created","issue":{"url":"https://api.github.com/repos/expo/expo/issues/1707","repository_url":"https://api.github.com/repos/expo/expo","labels_url":"https://api.github.com/repos/expo/expo/issues/1707/labels{/name}","comments_url":"https://api.github.com/repos/expo/expo/issues/1707/comments","events_url":"https://api.github.com/repos/expo/expo/issues/1707/events","html_url":"https://github.com/expo/expo/issues/1707","id":318547988,"node_id":"MDU6SXNzdWUzMTg1NDc5ODg=","number":1707,"title":"ImagePicker Promise Rejects on First Attempt Though Permission.CAMERA Granted","user":{"login":"geirman","id":1640318,"node_id":"MDQ6VXNlcjE2NDAzMTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1640318?v=4","gravatar_id":"","url":"https://api.github.com/users/geirman","html_url":"https://github.com/geirman","followers_url":"https://api.github.com/users/geirman/followers","following_url":"https://api.github.com/users/geirman/following{/other_user}","gists_url":"https://api.github.com/users/geirman/gists{/gist_id}","starred_url":"https://api.github.com/users/geirman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geirman/subscriptions","organizations_url":"https://api.github.com/users/geirman/orgs","repos_url":"https://api.github.com/users/geirman/repos","events_url":"https://api.github.com/users/geirman/events{/privacy}","received_events_url":"https://api.github.com/users/geirman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"esamelson","id":19958240,"node_id":"MDQ6VXNlcjE5OTU4MjQw","avatar_url":"https://avatars1.githubusercontent.com/u/19958240?v=4","gravatar_id":"","url":"https://api.github.com/users/esamelson","html_url":"https://github.com/esamelson","followers_url":"https://api.github.com/users/esamelson/followers","following_url":"https://api.github.com/users/esamelson/following{/other_user}","gists_url":"https://api.github.com/users/esamelson/gists{/gist_id}","starred_url":"https://api.github.com/users/esamelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esamelson/subscriptions","organizations_url":"https://api.github.com/users/esamelson/orgs","repos_url":"https://api.github.com/users/esamelson/repos","events_url":"https://api.github.com/users/esamelson/events{/privacy}","received_events_url":"https://api.github.com/users/esamelson/received_events","type":"User","site_admin":false},"assignees":[{"login":"esamelson","id":19958240,"node_id":"MDQ6VXNlcjE5OTU4MjQw","avatar_url":"https://avatars1.githubusercontent.com/u/19958240?v=4","gravatar_id":"","url":"https://api.github.com/users/esamelson","html_url":"https://github.com/esamelson","followers_url":"https://api.github.com/users/esamelson/followers","following_url":"https://api.github.com/users/esamelson/following{/other_user}","gists_url":"https://api.github.com/users/esamelson/gists{/gist_id}","starred_url":"https://api.github.com/users/esamelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esamelson/subscriptions","organizations_url":"https://api.github.com/users/esamelson/orgs","repos_url":"https://api.github.com/users/esamelson/repos","events_url":"https://api.github.com/users/esamelson/events{/privacy}","received_events_url":"https://api.github.com/users/esamelson/received_events","type":"User","site_admin":false}],"milestone":null,"comments":48,"created_at":"2018-04-27T20:59:18Z","updated_at":"2018-06-07T18:33:29Z","closed_at":"2018-06-07T18:11:47Z","author_association":"NONE","body":"### Summary\r\nGranting camera access then immediately using that access with `ImagePicker` results in a promise rejection `[Error: Missing camera or camera roll permission.]`. \r\n\r\n### Environment\r\nEnvironment:\r\n  OS: macOS High Sierra 10.13.4\r\n  Node: 8.2.1\r\n  Yarn: 1.2.1\r\n  npm: 5.3.0\r\n  Watchman: 4.9.0\r\n  Xcode: Xcode 9.3 Build version 9E145\r\n  Android Studio: 3.0 AI-171.4443003\r\n\r\nPackages: (wanted => installed)\r\n  expo: ^26.0.0 => 26.0.0\r\n  react: 16.3.0-alpha.1 => 16.3.0-alpha.1\r\n  react-native: https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz => 0.54.2\r\n\r\nDiagnostics report:\r\n  https://exp-xde-diagnostics.s3.amazonaws.com/geirman-9b12d065-1f0c-42c8-9884-9be91c7f5621.tar.gz\r\n\r\nExpo Client\r\n\r\n### Steps to Reproduce\r\n\r\n1. Load the demo app below\r\n2. Tap \"Pick from Camera\" button\r\n3. Tap to authorize camera access\r\n4. RESULT: camera fails to launch, note the output of console.log\r\n5. Tap \"Pick from Gallery\" button\r\n6. Tap to authorize camera roll access\r\n7. RESULT: camera roll launches as expected, note output of console.log\r\n8. Tap \"Pick from Camera\" again\r\n9. RESULT: camera launches, note the output of console.log (everything is fine at this point)\r\n\r\n### Expected Behavior\r\n\r\n**For bullet 4** above, I expect camera launch and the following output after taking a photo...\r\n\r\n```\r\ncamera granted\r\ncameraRoll SUCCESS Object {\r\n  \"cancelled\": false,\r\n  \"height\": 2848,\r\n  \"type\": \"image\",\r\n  \"uri\": \"file:///...54B7F932-9E42-443D-8B25-B41892A4C283.jpg\",\r\n  \"width\": 4288,\r\n}\r\n```\r\n\r\n**For bullet 7** above, I expect **camera roll** to launch and the following output after taking a photo...\r\n\r\n```\r\ncameraRoll granted\r\ncameraRoll SUCCESS Object {\r\n  \"cancelled\": false,\r\n  \"height\": 2848,\r\n  \"type\": \"image\",\r\n  \"uri\": \"file:///.../54B7F932-9E42-443D-8B25-B41892A4C283.jpg\",\r\n  \"width\": 4288,\r\n}\r\n\r\n```\r\n### Actual Behavior\r\nCamera is not working correctly on first attempt. To spite being \"granted\" access, the promise rejects and the following is the output. Repeatedly tapping \"Pick from Camera\" will repeatedly result in a promise rejection. However, once I \"Pick from Gallery\", then \"Pick from Camera\" will start working as expected. \r\n\r\n```\r\ncamera granted\r\ncamera Object {\r\n  \"error\": [Error: Missing camera or camera roll permission.],\r\n}\r\ncamera SUCCESS undefined\r\n```\r\n\r\n### Reproducible Demo\r\nhttps://snack.expo.io/@geirman/permissions-camera-camera-roll\r\n\r\n```\r\nimport React, { Component } from 'react';\r\nimport { View, StyleSheet, Button } from 'react-native';\r\nimport { Constants, Permissions, ImagePicker } from 'expo';\r\n\r\n\r\nexport default class App extends Component {\r\n  pickFromGallery = async () => {\r\n    const permissions = Permissions.CAMERA_ROLL;\r\n    const { status } = await Permissions.askAsync(permissions);\r\n\r\n    console.log(permissions, status);\r\n    if(status === 'granted') {\r\n      let image = await ImagePicker.launchImageLibraryAsync({\r\n        mediaTypes: 'Images',\r\n      }).catch(error => console.log(permissions, { error }));\r\n      console.log(permissions, 'SUCCESS', image);\r\n    }\r\n  }\r\n\r\n  pickFromCamera = async () => {\r\n    const permissions = Permissions.CAMERA;\r\n    const { status } = await Permissions.askAsync(permissions);\r\n\r\n    console.log(permissions, status);\r\n    if(status === 'granted') {\r\n      let image = await ImagePicker.launchCameraAsync({\r\n        mediaTypes: 'Images',\r\n      }).catch(error => console.log(permissions, { error }));\r\n      console.log(permissions, 'SUCCESS', image);\r\n    }\r\n  }\r\n\r\n\r\n\r\n  render() {\r\n    return (\r\n      <View style={styles.container}>\r\n\r\n        <Button\r\n          title=\"Pick from Camera\"\r\n          onPress={this.pickFromCamera}\r\n        />\r\n        <Button\r\n          title=\"Pick from Gallery\"\r\n          onPress={this.pickFromGallery}\r\n        />\r\n\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n    alignItems: 'center',\r\n    justifyContent: 'space-around',\r\n    paddingTop: Constants.statusBarHeight,\r\n    backgroundColor: '#ecf0f1',\r\n  },\r\n});\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/expo/expo/issues/comments/395521243","html_url":"https://github.com/expo/expo/issues/1707#issuecomment-395521243","issue_url":"https://api.github.com/repos/expo/expo/issues/1707","id":395521243,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTUyMTI0Mw==","user":{"login":"geirman","id":1640318,"node_id":"MDQ6VXNlcjE2NDAzMTg=","avatar_url":"https://avatars1.githubusercontent.com/u/1640318?v=4","gravatar_id":"","url":"https://api.github.com/users/geirman","html_url":"https://github.com/geirman","followers_url":"https://api.github.com/users/geirman/followers","following_url":"https://api.github.com/users/geirman/following{/other_user}","gists_url":"https://api.github.com/users/geirman/gists{/gist_id}","starred_url":"https://api.github.com/users/geirman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geirman/subscriptions","organizations_url":"https://api.github.com/users/geirman/orgs","repos_url":"https://api.github.com/users/geirman/repos","events_url":"https://api.github.com/users/geirman/events{/privacy}","received_events_url":"https://api.github.com/users/geirman/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T18:33:29Z","updated_at":"2018-06-07T18:33:29Z","author_association":"NONE","body":"I agree and probably should have closed it myself, but the conversation has been lively."}}
{"actor":{"display_login":"geirman"}}