Page MenuHomePhabricator

D6380.id21459.diff
No OneTemporary

D6380.id21459.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
@@ -5,6 +5,7 @@
import android.content.Context;
import android.os.Bundle;
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;
@@ -101,6 +102,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
@@ -16,6 +16,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
@@ -324,7 +324,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:41 AM (20 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675609
Default Alt Text
D6380.id21459.diff (2 KB)

Event Timeline