start adding payment

This commit is contained in:
Thomas Demirdjian
2025-11-04 14:46:12 +01:00
parent 02a2333a41
commit 4bb083ea46
24 changed files with 3507 additions and 7604 deletions
+40 -1
View File
@@ -9,7 +9,7 @@ import React, {
useRef,
useState,
} from "react";
import { Platform } from "react-native";
import { AppState, Platform } from "react-native";
import { useGlobal } from "reactn";
import firebase, {
arrayUnion,
@@ -66,6 +66,18 @@ export default function NotificationProvider({ children }) {
}
}, [notifications]);
const clearBadgeCount = useCallback(async () => {
if (Platform.OS === "web") {
return;
}
try {
await Notifications.setBadgeCountAsync(0);
} catch (error) {
console.log("clearBadgeCount error:", error);
}
}, []);
const markNotificationAsRead = useCallback(async (notificationId) => {
try {
if (!notificationId) return;
@@ -117,6 +129,33 @@ export default function NotificationProvider({ children }) {
registerForPushNotificationsAsync();
}, [user, uid, notifInit]);
useEffect(() => {
if (Platform.OS === "web") {
return;
}
clearBadgeCount();
const handleAppStateChange = (state) => {
if (state === "active") {
clearBadgeCount();
}
};
const subscription = AppState.addEventListener(
"change",
handleAppStateChange
);
return () => {
if (subscription?.remove) {
subscription.remove();
} else {
AppState.removeEventListener("change", handleAppStateChange);
}
};
}, [clearBadgeCount]);
useEffect(() => {
if (!allowNotifications) {
return;