From bdd0948dbfe79145716c519995a857212eb55775 Mon Sep 17 00:00:00 2001 From: Stephanie Wong Date: Fri, 26 Apr 2024 10:27:46 -0700 Subject: [PATCH 1/5] fix routing issue --- src/app/(BottomTabNavigation)/AllCases/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(BottomTabNavigation)/AllCases/index.tsx b/src/app/(BottomTabNavigation)/AllCases/index.tsx index dc564bb2..147ec3ff 100644 --- a/src/app/(BottomTabNavigation)/AllCases/index.tsx +++ b/src/app/(BottomTabNavigation)/AllCases/index.tsx @@ -86,7 +86,7 @@ function CasesScreen() { notificationListener.current = Notifications.addNotificationReceivedListener(notification => { - const updateId = notification.request.content.data['id']; + const updateId = notification.request.content.data.updateId; const debugString = 'NotificationRecieved: ' + notification + @@ -103,7 +103,7 @@ function CasesScreen() { responseListener.current = Notifications.addNotificationResponseReceivedListener(response => { - const updateId = response.notification.request.content.data['id']; + const updateId = response.notification.request.content.data.updateId; const debugString = 'NotificationResponseRecieved: ' + response + @@ -140,7 +140,7 @@ function CasesScreen() { ListHeaderComponent={() => ( <> - {notificationResponse} + {/* {notificationResponse} */} My Cases From 12cbfc9e2c745f88082de23c9a171642129c226a Mon Sep 17 00:00:00 2001 From: Stephanie Wong Date: Fri, 26 Apr 2024 10:34:11 -0700 Subject: [PATCH 2/5] comment out notification recieved listener --- .../(BottomTabNavigation)/AllCases/index.tsx | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/app/(BottomTabNavigation)/AllCases/index.tsx b/src/app/(BottomTabNavigation)/AllCases/index.tsx index 147ec3ff..dfe4a52b 100644 --- a/src/app/(BottomTabNavigation)/AllCases/index.tsx +++ b/src/app/(BottomTabNavigation)/AllCases/index.tsx @@ -84,22 +84,22 @@ function CasesScreen() { }); } - notificationListener.current = - Notifications.addNotificationReceivedListener(notification => { - const updateId = notification.request.content.data.updateId; - const debugString = - 'NotificationRecieved: ' + - notification + - ', ' + - notification.request + - ', ' + - notification.request.content + - ', ' + - notification.request.content.data; - console.log(debugString); - setNotificationResponse(debugString); - router.push(`/AllCases/Updates/UpdateView/${updateId}`); - }); + // notificationListener.current = + // Notifications.addNotificationReceivedListener(notification => { + // const updateId = notification.request.content.data.updateId; + // const debugString = + // 'NotificationRecieved: ' + + // notification + + // ', ' + + // notification.request + + // ', ' + + // notification.request.content + + // ', ' + + // notification.request.content.data; + // console.log(debugString); + // setNotificationResponse(debugString); + // router.push(`/AllCases/Updates/UpdateView/${updateId}`); + // }); responseListener.current = Notifications.addNotificationResponseReceivedListener(response => { @@ -121,9 +121,9 @@ function CasesScreen() { }); return () => { - Notifications.removeNotificationSubscription( - notificationListener.current!, - ); + // Notifications.removeNotificationSubscription( + // notificationListener.current!, + // ); Notifications.removeNotificationSubscription(responseListener.current!); }; From b11656be27b7a441d573c818229e8767d7981c2b Mon Sep 17 00:00:00 2001 From: Stephanie Wong Date: Fri, 26 Apr 2024 10:49:16 -0700 Subject: [PATCH 3/5] delete eas.json file --- eas.json | 40 ------------------- .../(BottomTabNavigation)/AllCases/index.tsx | 2 +- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 eas.json diff --git a/eas.json b/eas.json deleted file mode 100644 index 3b811d00..00000000 --- a/eas.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "cli": { - "version": ">= 3.6.0", - "promptToConfigurePushNotifications": false - }, - "build": { - "development": { - "developmentClient": true, - "distribution": "internal", - "ios": { - "resourceClass": "m-medium" - } - }, - "preview": { - "distribution": "internal", - "ios": { - "resourceClass": "m-medium" - }, - "android": { - "buildType": "apk" - } - }, - "preview2": { - "android": { - "gradleCommand": ":app:assembleRelease" - } - }, - "preview3": { - "developmentClient": true - }, - "production": { - "ios": { - "resourceClass": "m-medium" - } - } - }, - "submit": { - "production": {} - } -} diff --git a/src/app/(BottomTabNavigation)/AllCases/index.tsx b/src/app/(BottomTabNavigation)/AllCases/index.tsx index dfe4a52b..17909f32 100644 --- a/src/app/(BottomTabNavigation)/AllCases/index.tsx +++ b/src/app/(BottomTabNavigation)/AllCases/index.tsx @@ -28,7 +28,7 @@ function CasesScreen() { }), }); - const notificationListener = useRef(); + // const notificationListener = useRef(); const responseListener = useRef(); const { allCases, loading } = useContext(CaseContext); From 1c92e5f0222fbd088000b6efbf3449053c43a9b7 Mon Sep 17 00:00:00 2001 From: Stephanie Wong Date: Fri, 26 Apr 2024 10:58:13 -0700 Subject: [PATCH 4/5] add notification logo (might only work if deployed? --- app.json | 2 +- assets/notification-logo.png | Bin 0 -> 290 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/notification-logo.png diff --git a/app.json b/app.json index 68940bc6..2fa8fe2d 100644 --- a/app.json +++ b/app.json @@ -49,7 +49,7 @@ [ "expo-notifications", { - "icon": "./assets/icon.png", + "icon": "./assets/notification-logo.png", "color": "#ffffff" } ] diff --git a/assets/notification-logo.png b/assets/notification-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..8173e50bbd2742eb8905a35a15214d91cc3d0943 GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W~!3HFs%y=IPq&N#aB8wRqxP?KOkzv*x37{Zj zage(c!@6@aFM%AEbVpxD28NCO+lgw#ccXZA>qk_H{Okykl{8X}$QS35& zsF${7dhwKVMxQQA=9TyKxQALqr2Snm$&ESP=167Bj0ukW&uvPT-S7BZqA=EFT0@7^-YL#o9pV(r22h8Mq-m3*81sa?u*-v>_v#mu{ow$cY@*}vJa;`Y~V j7J)6CrgK9wYt8JBPPX-#@U?#z& Date: Mon, 3 Jun 2024 21:06:13 -0700 Subject: [PATCH 5/5] [fix] comment out deep linking logic for now. --- .../(BottomTabNavigation)/AllCases/index.tsx | 109 +++++++++--------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/src/app/(BottomTabNavigation)/AllCases/index.tsx b/src/app/(BottomTabNavigation)/AllCases/index.tsx index 6f448d24..8f56ffcc 100644 --- a/src/app/(BottomTabNavigation)/AllCases/index.tsx +++ b/src/app/(BottomTabNavigation)/AllCases/index.tsx @@ -1,4 +1,4 @@ -import * as Linking from 'expo-linking'; +// import * as Linking from 'expo-linking'; import * as Notifications from 'expo-notifications'; import { router } from 'expo-router'; import React, { useContext, useState, useEffect, useRef } from 'react'; @@ -16,20 +16,21 @@ import { } from '../../../supabase/pushNotifications'; import 'react-native-url-polyfill/auto'; -enum linkingEvents { - ADD_CASE = 'addCase', - NOTIFICATION = 'notification', -} -function CasesScreen() { - Notifications.setNotificationHandler({ - handleNotification: async () => ({ - shouldShowAlert: true, - shouldPlaySound: false, - shouldSetBadge: false, - }), - }); +// enum linkingEvents { +// ADD_CASE = 'addCase', +// NOTIFICATION = 'notification', +// } + +Notifications.setNotificationHandler({ + handleNotification: async () => ({ + shouldShowAlert: true, + shouldPlaySound: false, + shouldSetBadge: false, + }), +}); +function CasesScreen() { const notificationListener = useRef(); const responseListener = useRef(); @@ -37,48 +38,48 @@ function CasesScreen() { const { session } = useSession(); const [notificationResponse, setNotificationResponse] = useState(''); - const [url, setUrl] = useState(null); - - function urlRedirect(parsedUrl: Linking.ParsedURL) { - if (!parsedUrl) return; - // parse query params and determine routing - const { queryParams } = parsedUrl; - // determine routing from the event variable - if (queryParams?.event) { - const event = queryParams.event.toString(); - // TODO: determine a way to validate required parameters - // TODO: prevent users from routing to a case they're already involved in - if (event === linkingEvents.ADD_CASE) - router.push({ - pathname: `/AllCases/AddCase/${queryParams.caseUid}`, - }); - } - } - - function handleDeepLink(event: any) { - const parsedUrl = Linking.parse(event.url); - if (parsedUrl) { - setUrl(parsedUrl); - urlRedirect(parsedUrl); - } - } - - async function getInitialUrl() { - const initialUrl = await Linking.getInitialURL(); - if (initialUrl) { - const parsed = Linking.parse(initialUrl); - setUrl(parsed); - urlRedirect(parsed); - } - } + // const [url, setUrl] = useState(null); + + // function urlRedirect(parsedUrl: Linking.ParsedURL) { + // if (!parsedUrl) return; + // // parse query params and determine routing + // const { queryParams } = parsedUrl; + // // determine routing from the event variable + // if (queryParams?.event) { + // const event = queryParams.event.toString(); + // // TODO: determine a way to validate required parameters + // // TODO: prevent users from routing to a case they're already involved in + // if (event === linkingEvents.ADD_CASE) + // router.push({ + // pathname: `/AllCases/AddCase/${queryParams.caseUid}`, + // }); + // } + // } + + // function handleDeepLink(event: any) { + // const parsedUrl = Linking.parse(event.url); + // if (parsedUrl) { + // setUrl(parsedUrl); + // urlRedirect(parsedUrl); + // } + // } + + // async function getInitialUrl() { + // const initialUrl = await Linking.getInitialURL(); + // if (initialUrl) { + // const parsed = Linking.parse(initialUrl); + // setUrl(parsed); + // urlRedirect(parsed); + // } + // } useEffect(() => { - // will detect any incoming link requests, assuming the app is already open - Linking.addEventListener('url', handleDeepLink); - if (!url) { - // if the link opened the app, must route to the initial incoming route - getInitialUrl(); - } + // // will detect any incoming link requests, assuming the app is already open + // Linking.addEventListener('url', handleDeepLink); + // if (!url) { + // // if the link opened the app, must route to the initial incoming route + // getInitialUrl(); + // } if (session?.user) { registerForPushNotifications().then(async (token: string) => { @@ -142,7 +143,7 @@ function CasesScreen() { ListHeaderComponent={() => ( <> - {notificationResponse} + Notifications Debug: {notificationResponse} My Cases