|
@@ -5,6 +5,7 @@ import android.content.Intent;
|
5
|
5
|
import android.net.Uri;
|
6
|
6
|
import android.provider.Settings;
|
7
|
7
|
import android.support.v4.app.ActivityCompat;
|
|
8
|
+import android.support.v4.app.NotificationManagerCompat;
|
8
|
9
|
import android.support.v4.content.ContextCompat;
|
9
|
10
|
import android.support.v4.content.PermissionChecker;
|
10
|
11
|
|
|
@@ -23,9 +24,11 @@ import java.util.Locale;
|
23
|
24
|
public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
24
|
25
|
private final ReactApplicationContext reactContext;
|
25
|
26
|
private final PermissionsModule mPermissionsModule;
|
|
27
|
+ private final NotificationManagerCompat mNotificationManagerCompat;
|
26
|
28
|
|
27
|
29
|
public enum RNType {
|
28
|
30
|
LOCATION,
|
|
31
|
+ NOTIFICATION,
|
29
|
32
|
CAMERA,
|
30
|
33
|
MICROPHONE,
|
31
|
34
|
CONTACTS,
|
|
@@ -38,6 +41,7 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
38
|
41
|
super(reactContext);
|
39
|
42
|
this.reactContext = reactContext;
|
40
|
43
|
mPermissionsModule = new PermissionsModule(this.reactContext);
|
|
44
|
+ mNotificationManagerCompat = NotificationManagerCompat.from(this.reactContext);
|
41
|
45
|
}
|
42
|
46
|
|
43
|
47
|
@Override
|
|
@@ -55,6 +59,15 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
55
|
59
|
return;
|
56
|
60
|
}
|
57
|
61
|
|
|
62
|
+ if(permission.equals("notification")) {
|
|
63
|
+ if (mNotificationManagerCompat.areNotificationsEnabled()) {
|
|
64
|
+ promise.resolve("authorized");
|
|
65
|
+ } else {
|
|
66
|
+ promise.resolve("denied");
|
|
67
|
+ }
|
|
68
|
+ return;
|
|
69
|
+ }
|
|
70
|
+
|
58
|
71
|
int result = PermissionChecker.checkSelfPermission(this.reactContext, permission);
|
59
|
72
|
switch (result) {
|
60
|
73
|
case PermissionChecker.PERMISSION_DENIED:
|
|
@@ -131,6 +144,8 @@ public class ReactNativePermissionsModule extends ReactContextBaseJavaModule {
|
131
|
144
|
case STORAGE:
|
132
|
145
|
case PHOTO:
|
133
|
146
|
return Manifest.permission.READ_EXTERNAL_STORAGE;
|
|
147
|
+ case NOTIFICATION:
|
|
148
|
+ return permission;
|
134
|
149
|
default:
|
135
|
150
|
return null;
|
136
|
151
|
}
|