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
Step 1->
To create your project run this command:
Step 2->
Now initialise your project name. Replace your project name with RunTimePermission:
Now add permission in your AndroidManifest.xml file:
Path: android->src->AndroidManifest.xml
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
DOWNLOAD SOURCE CODE FROM HERE
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
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>
<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') } }
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
Looking to hire USA IOS Application Development Company Visit @wwww.meerakics.com, Contact us +91 7018300334.
ReplyDeleteThis content is well-detailed and easy to understand. Thank you for creating a good content!
ReplyDeletemulti vendor ecommerce app
Thanks for the great information. Looking for the best company for react native app development. Please check out here.
ReplyDeleteNice Article. Fresh Squeeze Design provides web design & development, branding, custom application development, SEO & Social Media Management services. For more details
ReplyDeleteMobile Application Development
Very nice and informative blog. Thanks for sharing with us.
ReplyDeleteNice Article.
ReplyDeleteAugurs 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
Great post. Thanks
ReplyDeleteReact Native App Development Company USA
Five Key Points to Consider While Outsourcing Your Social Networking Portal Development
ReplyDeleteFactors To Consider In Social Networking Portal Development
How Social Networking Portal Development Can Benefit Your Business
How Social Networking Portal Development Can Benefit Your Business
How to Hire an Android App Developer
5 Major Reasons Why iOS App Developer Is Essential For Your Business
Android Or Ios – Which Platform Should You Choose For Developing Your App
Why Iphone Apps Are Becoming Popular Popular
Tools Used For Android App Development
Top 7 Skills Of A Good iOS Programmer
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.
ReplyDeleteweb design company in USA
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.
ReplyDeleteThanks 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.
ReplyDeleteGreat Job!
ReplyDeleteReact 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
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.
ReplyDeleteios mobile app development
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.
ReplyDeleteKeep 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.
ReplyDeleteReact Native Development Services