diff --git a/app.json b/app.json index 1cb5551..6c4e83e 100644 --- a/app.json +++ b/app.json @@ -1,7 +1,7 @@ { "expo": { "name": "Tones", - "slug": "Tones", + "slug": "tones", "version": "1.0.1", "orientation": "portrait", "icon": "./assets/images/icon.png", @@ -29,6 +29,15 @@ ], "experiments": { "typedRoutes": true - } + }, + "extra": { + "router": { + "origin": false + }, + "eas": { + "projectId": "6903a306-dafd-42ab-b010-f0c8205269ad" + } + }, + "owner": "mattdimegs" } } diff --git a/app/login.jsx b/app/login.jsx index 0ad234f..df2b282 100644 --- a/app/login.jsx +++ b/app/login.jsx @@ -21,11 +21,13 @@ import { TextLinkContent, LoginTextInput } from '../components/generalHelpers.jsx'; +import { useNotifications } from '@/hooks'; export default function Login() { const [hidePassword, setHidePassword] = useState(true); const [loginButtonDisabled, setLoginButtonDisabled] = useState(true); const [auth, setAuth] = useState(false); + const { expoPushToken } = useNotifications(); const formik = useFormik({ initialValues: { @@ -122,6 +124,7 @@ export default function Login() { Landing + View Token: {expoPushToken} diff --git a/hooks/useNotifications/useNotifications.jsx b/hooks/useNotifications/useNotifications.jsx index 80521fe..964b35a 100644 --- a/hooks/useNotifications/useNotifications.jsx +++ b/hooks/useNotifications/useNotifications.jsx @@ -43,30 +43,29 @@ const registerForPushNotificationsAsync = async () => { const { status: existingStatus } = await Notifications.getPermissionsAsync(); let finalStatus = existingStatus; if (existingStatus !== 'granted') { - const { status } = await Notifications.requestPermissionsAsync(); - finalStatus = status; + const { status } = await Notifications.requestPermissionsAsync(); + finalStatus = status; } if (finalStatus !== 'granted') { - alert('Failed to get push token for push notification!'); + alert('Failed to get push token for push notification!'); return; } // Learn more about projectId: // https://docs.expo.dev/push-notifications/push-notifications-setup/#configure-projectid // EAS projectId is used here. try { - const projectId = - Constants?.expoConfig?.extra?.eas?.projectId ?? Constants?.easConfig?.projectId; - if (!projectId) { - throw new Error('Project ID not found'); - } - token = ( + const projectId = + Constants?.expoConfig?.extra?.eas?.projectId ?? Constants?.easConfig?.projectId; + if (!projectId) { + throw new Error('Project ID not found'); + } + token = ( await Notifications.getExpoPushTokenAsync({ - projectId, + projectId, }) - ).data; - console.log(token); + ).data; } catch (e) { - token = `${e}`; + token = `${e}`; } } else { alert('Must use physical device for Push Notifications');