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

15 comments:

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

    multi vendor ecommerce app

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

    ReplyDelete
  3. 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
  4. Very nice and informative blog. Thanks for sharing with us.

    ReplyDelete
  5. 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
  6. Very informative blog, keep posting. I will surely share your blog with my friends and more. I always love to read your blogs. Thanks for posting this content.
    web design company in USA

    ReplyDelete
  7. Thank you for sharing. Alteza holds an upper hand in Telemedicine App Development. We make telemedicine applications that will give the advantage of consultation anytime and anywhere for your patients.

    ReplyDelete
  8. Thanks for sharing such informative content with us... Keep posting! Best mobile application development agency offers quality android & iOS mobile app development service for every industry. For more information, contact us: +919500788278.

    ReplyDelete
  9. Great Job!
    React Native has been gaining significant momentum in recent years due to its versatility and efficiency in app development. Its ability to create cross-platform apps for both Android and iOS has made it a top choice for businesses seeking to reach a wider audience.

    Hire React Native Developers
    Hire Mobile App Developers
    Hire Flutter
    Developers

    ReplyDelete
  10. Apple iOS stands for iPhone operating system and is designed for use with Apple's multitouch devices. The mobile OS supports input through direct manipulation and responds to various user gestures, such as pinching, tapping and swiping.
    ios mobile app development

    ReplyDelete
  11. Thank you for sharing insights on runtime permission in react native. Handling permissions is crucial for user experience. Every mobile app development company should implement better user experience and also demonstrates a commitment to safeguarding user data.

    ReplyDelete
  12. Keep writing on this very useful blog. I will definitely share your blog with my fellow bloggers and others. I always enjoy reading your site posts. Thank you for publishing this content.
    React Native Development Services

    ReplyDelete