Deepshikha Puri, the young Indian Entrepreneur heading the mobile development trade from years to successive extent, has worked with numerous clients and many tremendous brands in this industry of mobile encompassing in India and overseas maintaining promising work relationships with each of them with an impression to manage it's whole thing.

Sunday, November 10, 2019

Runtime Permission In React Native

Video Demo:

There are two type of permissions: Normal and Dangerous permission.
Normal permission are like Internet permission, network permission etc and Dangerous permission contain the private data of users like contact details, gallery etc. Before Android version 6 these permissions are showed while installing the application but there is not method to change these permission during running app. But now in latest version permission system has been changed and now user can deny these permission in running app.

DOWNLOAD SOURCE CODE FROM BELOW
permissions android react native example react native android runtime permission

react-native-permissions example Request Runtime permission React Native

Step 1->
To create your project run this command:
sudo npm install -g react-native-cli
Step 2-> 
Now initialise your project name. Replace your project name with RunTimePermission:
react-native init RunTimePermission

Now add permission in your AndroidManifest.xml file:
Path: android->src->AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.runtimepermissions">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.CAMERA" />
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> </application>
</manifest>

Now you can start work on your React js classes

App.js


import React, {Component} from 'react'; import { StyleSheet, Text, View,StatusBar,Button} from 'react-native'; import { runTimePermissions } from './functions/runPermissions'; export default class App extends Component {
async btnCamera(){ await runTimePermissions() }
render() { return ( <View style={styles.container}> <StatusBar backgroundColor='#FF7043'></StatusBar> <View style={styles.bar}> <Text style={styles.txt}>Run Time Permissions</Text> </View>
<View style={styles.btncontainer}> <Button color='#FF5722' title='CAMERA' onPress={this.btnCamera.bind(this)}></Button> </View>
</View> ); } }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F5FCFF', },
bar:{ backgroundColor:'#FF5722', height: 50, justifyContent: 'center' },

btncontainer:{ flex:1, backgroundColor: 'white', justifyContent: 'center', padding:10 },
txt:{ color: 'white', textAlign:'center', },
button: { backgroundColor: '#00aeef', borderColor: 'red', borderWidth: 5, borderRadius: 15, color: 'black' } });


runPermission.js

import {PermissionsAndroid} from 'react-native'
export async function runTimePermissions() { const grant= await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.CAMERA )
if(grant==PermissionsAndroid.RESULTS.GRANTED){ alert('Run time permissions granted') }else{ alert('Run time permissions denied') } }

DOWNLOAD SOURCE CODE FROM HERE

19 comments:

  1. I really enjoyed this post. You describe this topic very well. I really enjoy reading your blog and I will definitely bookmark it! Keep up the interesting posts!

    flutter app

    ReplyDelete
  2. Thanks for sharing.
    Looking for Mobile Apps Development Company in Patna Bihar Cybonetic Technologies providing the best mobile apps( Andriod, IOS) development service in Patna Bihar.

    ReplyDelete
  3. Thanks for sharing..
    Cybonetic Technologies IT & Software Development Company in Patna, focusing on the development of software, mobile app, e-comm, web hosting, bulk sms, Digital Marketing services.

    ReplyDelete
  4. This content is well-detailed and easy to understand. Thank you for creating a good content!

    multi vendor ecommerce app

    ReplyDelete
  5. A well informative blog which speaks about Mobile applications hands-on experience like these helps us to become an Android application developer.

    ReplyDelete
  6. Thanks for the great information. Looking for the best company for react native app development. Please check out here.

    ReplyDelete

  7. Thank you for sharing..
    Looking for a software development company in Patna, Cybonetic Technologies is the best Software Development Company Patna, Bihar. Call us to know more

    ReplyDelete
  8. Nice Article, Thank you for sharing a wonderful blog post
    Mobile App Development Company in Noida

    ReplyDelete
  9. Nice Article, Thank you for sharing a wonderful blog post, I loved your blog post.

    You can also check - Telemedicine App Development Company

    ReplyDelete
  10. Nice Article. Fresh Squeeze Design provides web design & development, branding, custom application development, SEO & Social Media Management services. For more details
    Mobile Application Development

    ReplyDelete
  11. Very nice and informative blog. Thanks for sharing with us.

    ReplyDelete
  12. Nice Article.
    Augurs Technologies is a single point of contact for software development services and platforms that provide specialized solutions. We develop software for various sectors, such as retail, finance, education, healthcare and housing, hospitality, maritime transport, electronics industry. Our software development allows the company to reach the highest level of competence to obtain the best possible return. Our technical team is experienced and qualified to meet customer demands. We are uniquely committed to providing a first-stop solution.
    Augurs Technologies

    ReplyDelete
  13. I have never seen this type of article post. It's amazing every topic defined deeply. Thanks for sharing it.
    You can visit here for Website designing company in Delhi ncr and
    Website Development company in Delhi

    ReplyDelete
  14. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site. For more info:- React native App Development

    ReplyDelete