Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How create permissions for react native when on click necessary module ? #15358

Closed
boga01 opened this issue Aug 3, 2017 · 1 comment
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@boga01
Copy link

boga01 commented Aug 3, 2017

I'm new to react native. I wrote the following code to call a function, if a user clicks on a camera.In addition I've a camera module how to call camera module on this partition at code.Code is run but it is call function while project starting,I want to click camera button and ask user camera options allow or deny question.I referenced yonahfrostproject esspecially example.js file I focused on but I don't understand it.

render () {
return (<TouchableOpacity onPress={this.openCamera}> 
<View> ???  </View> 
</TouchableOpacity> 
   
     )
  }

Plus my full code is here;

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

interface Props {
names: string[]
}

interface PermissionsState {
status: PermissionStatus
}

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

class Permissions {
static request(arg0: any): any {
    throw new Error('Method not implemented.')
}
static RESULTS: any
static PERMISSIONS: any
openCamera: any
public async requestCameraPermission() {
    try {
        const granted = await Permissions.request(
            Permissions.PERMISSIONS.CAMERA,
        )
        if (granted === Permissions.RESULTS.GRANTED) {
            // console.log("kamerayı kullanabilirsiniz")
        } else {
            // console.log('kamerayı kullanamazsınız')
        }
    } catch (err) {
        // console.warn(err)
    }
    
}
render () {
return (<TouchableOpacity onPress={this.openCamera}> 
<View> <Text>openCamera</Text> </View> 
</TouchableOpacity> 
   
    )
}

}

export default new Permissions()
@hramos
Copy link
Contributor

hramos commented Aug 3, 2017

This issue looks like a question that would be best asked on StackOverflow.

StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only.

Will close this as this is really a question that should be asked on StackOverflow.

@hramos hramos closed this as completed Aug 3, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Aug 3, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants