From d5e48080617fd39c78e6337866e2a2665f65ec86 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Thu, 31 May 2018 16:31:27 +0200 Subject: [PATCH] [android][messaging] Support for hasPermission using areNotificationsEnabled --- .../io/invertase/firebase/messaging/RNFirebaseMessaging.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java index 78b67b61..19f36bd6 100644 --- a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java +++ b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessaging.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.app.NotificationManagerCompat; import android.util.Log; import com.facebook.react.bridge.Promise; @@ -56,7 +57,8 @@ public class RNFirebaseMessaging extends ReactContextBaseJavaModule { // Non Web SDK methods @ReactMethod public void hasPermission(Promise promise) { - promise.resolve(true); + Boolean enabled = NotificationManagerCompat.from(getReactApplicationContext()).areNotificationsEnabled(); + promise.resolve(enabled); } @ReactMethod