How to use the react-native-unimodules.Permissions.AUDIO_RECORDING 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 / audio.ts View on Github external
async play () {
    const status = await askAsyncPermissions(Permissions.AUDIO_RECORDING)

    if (status !== 'granted') {
      const res = {errMsg: `Permissions denied!`}
      return Promise.reject(res)
    }

    const soundStatus = await this.soundObject.getStatusAsync()
    try {
      if (soundStatus.isLoaded === false && (soundStatus as any).isPlaying === undefined) {
        // First load
        await this._firstPlay()

      } else {
        await this.soundObject.playAsync()
      }
      // TODO
github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export const requestAudioPermission = async () => {
  let chargeForward = true
  const {Permissions} = require('react-native-unimodules')
  let {status} = await Permissions.getAsync(Permissions.AUDIO_RECORDING)
  if (status === Permissions.PermissionStatus.UNDETERMINED) {
    if (isIOS) {
      const askRes = await Permissions.askAsync(Permissions.AUDIO_RECORDING)
      status = askRes.status
    } else {
      const askRes = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO)
      switch (askRes) {
        case 'never_ask_again':
        case 'denied':
          status = Permissions.PermissionStatus.DENIED
      }
    }
    chargeForward = false
  }
  if (status === Permissions.PermissionStatus.DENIED) {
    throw new Error('Please allow Keybase to access the microphone in the phone settings.')
  }
  return chargeForward
}
github keybase / client / shared / actions / platform-specific / index.native.tsx View on Github external
export const requestAudioPermission = async () => {
  let chargeForward = true
  const {Permissions} = require('react-native-unimodules')
  let {status} = await Permissions.getAsync(Permissions.AUDIO_RECORDING)
  if (status === Permissions.PermissionStatus.UNDETERMINED) {
    if (isIOS) {
      const askRes = await Permissions.askAsync(Permissions.AUDIO_RECORDING)
      status = askRes.status
    } else {
      const askRes = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO)
      switch (askRes) {
        case 'never_ask_again':
        case 'denied':
          status = Permissions.PermissionStatus.DENIED
      }
    }
    chargeForward = false
  }
  if (status === Permissions.PermissionStatus.DENIED) {
    throw new Error('Please allow Keybase to access the microphone in the phone settings.')
github NervJS / taro / packages / taro-rn / src / api / media / record.ts View on Github external
async start (opts = {}) {

    const status = await askAsyncPermissions(Permissions.AUDIO_RECORDING)
    if (status !== 'granted') {
      const res = {errMsg: `Permissions denied!`}
      return Promise.reject(res)
    }

    const {
      duration = 60000,
      sampleRate = 8000,
      numberOfChannels = 2,
      encodeBitRate = 48000,
      format = 'aac',
      frameSize,
      audioSource = 'auto'
    }: any = opts
    let options = {
      android: Object.assign({}, RecorderManager.RecordingOptions.android, {sampleRate, numberOfChannels, bitRate: encodeBitRate}),