Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486807
D6380.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6380.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 5:59 AM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675609
Default Alt Text
D6380.diff (2 KB)
Attached To
Mode
D6380: Implement native method to check for notifications permissions and use it in JavaScript
Attached
Detach File
Event Timeline
Log In to Comment