|
|
@@ -5,6 +5,7 @@ import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.provider.Settings;
|
|
|
import android.support.v4.app.ActivityCompat;
|
|
|
+import android.support.v4.app.NotificationManagerCompat;
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
import android.support.v4.content.PermissionChecker;
|
|
|
|
|
|
@@ -23,9 +24,11 @@ import java.util.Locale;
|
|
|
public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
|
|
private final ReactApplicationContext reactContext;
|
|
|
private final PermissionsModule mPermissionsModule;
|
|
|
+ private final NotificationManagerCompat mNotificationManagerCompat;
|
|
|
|
|
|
public enum RNType {
|
|
|
LOCATION,
|
|
|
+ NOTIFICATION,
|
|
|
CAMERA,
|
|
|
MICROPHONE,
|
|
|
CONTACTS,
|
|
|
@@ -38,6 +41,7 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
|
|
super(reactContext);
|
|
|
this.reactContext = reactContext;
|
|
|
mPermissionsModule = new PermissionsModule(this.reactContext);
|
|
|
+ mNotificationManagerCompat = NotificationManagerCompat.from(this.reactContext);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -55,6 +59,15 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if(permission.equals("notification")) {
|
|
|
+ if (mNotificationManagerCompat.areNotificationsEnabled()) {
|
|
|
+ promise.resolve("authorized");
|
|
|
+ } else {
|
|
|
+ promise.resolve("denied");
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
int result = PermissionChecker.checkSelfPermission(this.reactContext, permission);
|
|
|
switch (result) {
|
|
|
case PermissionChecker.PERMISSION_DENIED:
|
|
|
@@ -131,6 +144,8 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
|
|
case STORAGE:
|
|
|
case PHOTO:
|
|
|
return Manifest.permission.READ_EXTERNAL_STORAGE;
|
|
|
+ case NOTIFICATION:
|
|
|
+ return permission;
|
|
|
default:
|
|
|
return null;
|
|
|
}
|