How to use the react-native-unimodules.Permissions.CAMERA_ROLL function in react-native-unimodules

To help you get started, we’ve selected a few react-native-unimodules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NervJS / taro / packages / taro-rn / src / api / media / saveMedia.js View on Github external
async function saveMedia (opts, type, API) {
  const { status } = await askAsyncPermissions(Permissions.CAMERA_ROLL)
  if (status !== 'granted') {
    const res = { errMsg: 'Permissions denied!' }
    return Promise.reject(res)
  }
  const { filePath, success, fail, complete } = opts
  const res = { errMsg: `${API}:ok` }

  return CameraRoll.saveToCameraRoll(filePath, type)
    .then((url) => {
      res.path = url
      success && success(res)
      complete && complete(res)
      return Promise.resolve(res)
    }).catch((err) => {
      res.errMsg = err.message
      fail && fail(res)