start adding payment
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user