Skip to content

Commit

Permalink
feat/LIVE-2536-llm-notifications-prompts console logs removed
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrellard-ledger committed Jul 20, 2022
1 parent 9bb7d9f commit 1767873
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
26 changes: 11 additions & 15 deletions apps/ledger-live-mobile/src/logic/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,18 @@ const useNotifications = () => {
const navigation = useNavigation();

const getIsNotifEnabled = async () => {
console.log("--- HAS PERM ---");
const authStatus = await messaging().hasPermission();
console.log("AUTH STATUS :", authStatus);
console.log("AUTHORIZED :", messaging.AuthorizationStatus.AUTHORIZED);
console.log("PROVISIONAL :", messaging.AuthorizationStatus.PROVISIONAL);


return authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
authStatus === messaging.AuthorizationStatus.PROVISIONAL;
};

const listenForNotifications = useCallback(async () => {
console.log("LISTEN");
if (!notificationsToken) {
const token = await messaging().getToken();
setNotificationsToken(token);
messaging().onMessage(async remoteMessage => {
console.log("NOTIF FOREGROUND", remoteMessage);
if (remoteMessage && remoteMessage.notification) {
console.log("ID :", remoteMessage.messageId);
pushToast({
id: remoteMessage.messageId,
title: remoteMessage.notification.title,
Expand All @@ -127,14 +120,13 @@ const useNotifications = () => {
});
}
});
// Needed to avoid a warning
messaging().setBackgroundMessageHandler(async remoteMessage => {
console.log("NOTIF BACKGROUND", JSON.stringify(remoteMessage));
});
}
}, [notificationsToken]);

const clearNotificationsListeners = useCallback(() => {
console.log("CLEAR");
if (notificationsToken) {
messaging().deleteToken(notificationsToken);
setNotificationsToken(undefined);
Expand All @@ -144,8 +136,15 @@ const useNotifications = () => {
const handlePushNotificationsPermission = useCallback(async () => {
if (Platform.OS === "android") {
Linking.openSettings();
} else {
const permission = await messaging().hasPermission();

if (permission === messaging.AuthorizationStatus.DENIED) {
Linking.openSettings();
} else if (permission === messaging.AuthorizationStatus.NOT_DETERMINED) {
messaging().requestPermission();
}
}
messaging().requestPermission();
}, []);

const setPushNotificationsModalOpenCallback = useCallback(
Expand All @@ -155,7 +154,6 @@ const useNotifications = () => {
dispatch(setNotificationsModalOpen(isModalOpen));
} else {
getIsNotifEnabled().then(isNotifEnabled => {
console.log("OPEN MODAL", isNotifEnabled, notificationsSettings.allowed);
if (!isNotifEnabled || !notificationsSettings.allowed) {
dispatch(setNotificationsModalOpen(isModalOpen));
}
Expand Down Expand Up @@ -228,16 +226,14 @@ const useNotifications = () => {
eventTrigger.route_name === pushNotificationsOldRoute),
[pushNotificationsOldRoute],
);

const onRouteChange = useCallback(
newRoute => {
if (pushNotificationsEventTriggered?.timeout) {
clearTimeout(pushNotificationsEventTriggered?.timeout);
}

console.log("ON ROUTE CHANGE",JSON.stringify(pushNotificationsDataOfUser, null, 2));
if (!areConditionsMet()) return;
console.log("CONDITIONS MET");

for (const eventTrigger of pushNotificationsFeature?.params?.trigger_events) {
if (isEventTriggered(eventTrigger, newRoute)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ export default function SnackbarContainer() {
icon: "info",
};

console.log("TOASTS", JSON.stringify(toasts, null, 4));

return hasCompletedOnboarding &&
toasts &&
toasts.length &&
Expand Down

0 comments on commit 1767873

Please sign in to comment.