Run npm i react-native-can-draw-overlays
auto links the module
react-native link react-native-can-draw-overlays
- Edit your
android/settings.gradle
to look like this (exclude +)
+ include ':react-native-can-draw-overlays'
+ project(':react-native-can-draw-overlays').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-can-draw-overlays/android')
- Edit your
android/app/build.gradle
(note: app folder) to look like this (exclude +)
dependencies {
+ implementation project(':react-native-can-draw-overlays')
}
- Edit your
MainApplication.java
from (android/app/src/main/java/...
) to look like this (exclude +)
+ import ru.enniel.candrawoverlays.CanDrawOverlaysPackage;
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
+ new CanDrawOverlaysPackage()
);
}
import { isOverlayPermissionGranted, requestOverlayPermission } from 'react-native-can-draw-overlays';
...
let granted = await isOverlayPermissionGranted();
if (!granted) {
granted = await requestOverlayPermission()
}
...