Skip to content

How to import permissions module on react native project? #15308

Closed
@boga01

Description

@boga01

I'm new at react native and typescript.I wanna create permissions module for my react native project and I seperated two links at below Yonah's project and Facebook's permissions project

Additionaly

npm install ,npm start , yarn run build --watch and react-native run-android

command running smoothly but permission module dont use it ,I dont present this module add my project.
And my trying link at below ;

const permission = require('react-native-permissions')
import React from 'react'
import {
StyleSheet,
TouchableHighlight,
Text,
View,
Alert,
AppState,
Platform,
PermissionsAndroid,
} from 'react-native'

interface Props {
names: string[]
}

interface PermissionsState {
status: PermissionStatus
}

type PermissionStatus = 'granted' | 'denied' | 'never_ask_again' | ''

export class permissions extends React.Component<Props, PermissionsState>
{
constructor(props: Props, context: any)
// tslint:disable-next-line:brace-style
{
    super(props, context)

    this.state = {
        status: '',
    }
}

public render()
// tslint:disable-next-line:brace-style
{
    return (<View> a </View>)
}
 }

 async function requestCameraPermission() {
try {
    const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.CAMERA,

    )
    if (granted === PermissionsAndroid.RESULTS.GRANTED) {
        // console.log("kamerayı kullanabilirsiniz")
    } else {
        // console.log('kamerayı kullanamazsınız')
    }
  } catch (err) {
    // console.warn(err)
  }
  }

  export default permission

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.Resolution: For Stack OverflowA question for Stack Overflow. Applying this label will cause issue to be closed.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions