videosdk-rn-android-overlay-permission
v1.0.6
Published
Overlay Permission for Android apps
Downloads
191
Maintainers
Readme
videosdk-rn-android-overlay-permission
This module is to request screen overlay permission from user in react-native based android application.
Getting started
$ npm install videosdk-rn-android-overlay-permission --save
Mostly automatic installation
$ react-native link videosdk-rn-android-overlay-permission
Add these permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.overlaypermission.OverlayPermissionPackage;
to the imports at the top of the file
Append the following lines to
android/settings.gradle
:include ':videosdk-rn-android-overlay-permission' project(':videosdk-rn-android-overlay-permission').projectDir = new File(rootProject.projectDir, '../node_modules/videosdk-rn-android-overlay-permission/android')
Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':videosdk-rn-android-overlay-permission')
Usage
//requestOverlayPermission Navigates to permission settings
OverlayPermissionModule.requestOverlayPermission();
import OverlayPermissionModule from "videosdk-rn-android-overlay-permission";
if (Platform.OS === "android") {
OverlayPermissionModule.isRequestOverlayPermissionGranted((status: any) => {
if (status) {
Alert.alert(
"Permissions",
"Overlay Permission",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel",
},
{
text: "OK",
onPress: () => OverlayPermissionModule.requestOverlayPermission(),
},
],
{ cancelable: false }
);
}
});
}