Skip to content

Instantly share code, notes, and snippets.

View ShanikaNishadhi's full-sized avatar

Shanika Wickramasinghe ShanikaNishadhi

View GitHub Profile
...
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
...
ext {
googlePlayServicesVersion = "+" // default: "+"
firebaseMessagingVersion = "+" // default: "+"
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
DeviceInfo.getBatteryLevel().then(batteryLevel => {
// 0.759999
});
DeviceInfo.getAndroidId().then(androidId => {
// androidId here
});
import { PermissionsAndroid } from 'react-native';
import Contacts from 'react-native-contacts';
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'Let us us access your contacts',
'buttonPositive': 'Please accept'
}
class App extends Component {
render() {
return (
<View style={styles.container}>
<RNCamera
style={{ flex: 1, alignItems: 'center' }}
ref={ref => {
this.camera = ref
}}
/>
import {check, PERMISSIONS, RESULTS} from 'react-native-permissions';
check(PERMISSIONS.IOS.CAMERA)
.then((result) => {
switch (result) {
case RESULTS.UNAVAILABLE:
console.log(
'feature is not available',
);
break;
DeviceInfo.isCameraPresent()
.then(isCameraPresent => {
// true or false
})
.catch(cameraAccessException => {
// is thrown if a camera device could not be queried or opened by the CameraManager on Android
});
import React from "react"
const ComponentOne = ({ children }) => {
return (
<div>
<h5>This is the component one</h5>;
{ children }
</div>
);
}
const App = () => {
const content = "Which component is using the content?";
return (
<div className="App">
<ComponentOne>
<ComponentTwo>
<ComponentThree>
<ComponentUsingProps content={content} />
<ComponentThree>
</ComponentTwo>