Skip to content

Commit

Permalink
fix NotificationManager call
Browse files Browse the repository at this point in the history
  • Loading branch information
hubermat committed May 18, 2020
1 parent 9e9655f commit 5f6c798
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion android/src/main/java/com/reactlibrary/RNRingerMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ public class RNRingerMode extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;
private AudioManager am;
private NotificationManager nm;

public RNRingerMode(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
am = (AudioManager) reactContext.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
nm = (NotificationManager) reactContext.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
}

@Override
Expand Down Expand Up @@ -54,7 +56,11 @@ public void getRingerMode(Promise promise) {

@ReactMethod
public void getInterruptionFilter(Promise promise) {
int filter = NotificationManager.getCurrentInterruptionFilter();
if (nm == null) {
promise.resolve("UNKNOWN");
return;
}
int filter = nm.getCurrentInterruptionFilter();
switch(filter) {
case NotificationManager.INTERRUPTION_FILTER_PRIORITY:
promise.resolve("PRIORITY");
Expand Down

0 comments on commit 5f6c798

Please sign in to comment.