Page MenuHomePhabricator

D6380.id21295.diff
No OneTemporary

D6380.id21295.diff

diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommAndroidNotifications.java
@@ -4,6 +4,7 @@
import android.app.NotificationManager;
import android.content.Context;
import android.service.notification.StatusBarNotification;
+import androidx.core.app.NotificationManagerCompat;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -90,6 +91,14 @@
notificationManager.cancelAll();
}
+ @ReactMethod
+ public void hasPermission(Promise promise) {
+ Boolean enabled =
+ NotificationManagerCompat.from(getReactApplicationContext())
+ .areNotificationsEnabled();
+ promise.resolve(enabled);
+ }
+
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
diff --git a/native/push/android.js b/native/push/android.js
--- a/native/push/android.js
+++ b/native/push/android.js
@@ -11,6 +11,7 @@
+getConstants: () => { NOTIFICATIONS_IMPORTANCE_HIGH: number, ... },
+setBadge: (count: number) => void,
+removeAllDeliveredNotifications: () => void,
+ +hasPermission: () => Promise<boolean>,
...
};
export type AndroidForegroundMessage = {
diff --git a/native/push/push-handler.react.js b/native/push/push-handler.react.js
--- a/native/push/push-handler.react.js
+++ b/native/push/push-handler.react.js
@@ -323,7 +323,7 @@
async ensureAndroidPushNotifsEnabled() {
const firebase = getFirebase();
- const hasPermission = await firebase.messaging().hasPermission();
+ const hasPermission = await CommAndroidNotifications.hasPermission();
if (!hasPermission) {
this.failedToRegisterPushPermissions();
return;

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 8:14 AM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676062
Default Alt Text
D6380.id21295.diff (2 KB)

Event Timeline