Add Project ID
This commit is contained in:
parent
051837968a
commit
0f3ef6aee5
3 changed files with 26 additions and 15 deletions
13
app.json
13
app.json
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"expo": {
|
"expo": {
|
||||||
"name": "Tones",
|
"name": "Tones",
|
||||||
"slug": "Tones",
|
"slug": "tones",
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/images/icon.png",
|
"icon": "./assets/images/icon.png",
|
||||||
|
|
@ -29,6 +29,15 @@
|
||||||
],
|
],
|
||||||
"experiments": {
|
"experiments": {
|
||||||
"typedRoutes": true
|
"typedRoutes": true
|
||||||
}
|
},
|
||||||
|
"extra": {
|
||||||
|
"router": {
|
||||||
|
"origin": false
|
||||||
|
},
|
||||||
|
"eas": {
|
||||||
|
"projectId": "6903a306-dafd-42ab-b010-f0c8205269ad"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"owner": "mattdimegs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,13 @@ import {
|
||||||
TextLinkContent,
|
TextLinkContent,
|
||||||
LoginTextInput
|
LoginTextInput
|
||||||
} from '../components/generalHelpers.jsx';
|
} from '../components/generalHelpers.jsx';
|
||||||
|
import { useNotifications } from '@/hooks';
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
const [hidePassword, setHidePassword] = useState(true);
|
const [hidePassword, setHidePassword] = useState(true);
|
||||||
const [loginButtonDisabled, setLoginButtonDisabled] = useState(true);
|
const [loginButtonDisabled, setLoginButtonDisabled] = useState(true);
|
||||||
const [auth, setAuth] = useState(false);
|
const [auth, setAuth] = useState(false);
|
||||||
|
const { expoPushToken } = useNotifications();
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
|
|
@ -122,6 +124,7 @@ export default function Login() {
|
||||||
<TextLinkContent>Landing</TextLinkContent>
|
<TextLinkContent>Landing</TextLinkContent>
|
||||||
</Link>
|
</Link>
|
||||||
</View>
|
</View>
|
||||||
|
<Text>View Token: {expoPushToken}</Text>
|
||||||
<Line />
|
<Line />
|
||||||
</InnerContainer>
|
</InnerContainer>
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
|
|
|
||||||
|
|
@ -43,30 +43,29 @@ const registerForPushNotificationsAsync = async () => {
|
||||||
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
const { status: existingStatus } = await Notifications.getPermissionsAsync();
|
||||||
let finalStatus = existingStatus;
|
let finalStatus = existingStatus;
|
||||||
if (existingStatus !== 'granted') {
|
if (existingStatus !== 'granted') {
|
||||||
const { status } = await Notifications.requestPermissionsAsync();
|
const { status } = await Notifications.requestPermissionsAsync();
|
||||||
finalStatus = status;
|
finalStatus = status;
|
||||||
}
|
}
|
||||||
if (finalStatus !== 'granted') {
|
if (finalStatus !== 'granted') {
|
||||||
alert('Failed to get push token for push notification!');
|
alert('Failed to get push token for push notification!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Learn more about projectId:
|
// Learn more about projectId:
|
||||||
// https://docs.expo.dev/push-notifications/push-notifications-setup/#configure-projectid
|
// https://docs.expo.dev/push-notifications/push-notifications-setup/#configure-projectid
|
||||||
// EAS projectId is used here.
|
// EAS projectId is used here.
|
||||||
try {
|
try {
|
||||||
const projectId =
|
const projectId =
|
||||||
Constants?.expoConfig?.extra?.eas?.projectId ?? Constants?.easConfig?.projectId;
|
Constants?.expoConfig?.extra?.eas?.projectId ?? Constants?.easConfig?.projectId;
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
throw new Error('Project ID not found');
|
throw new Error('Project ID not found');
|
||||||
}
|
}
|
||||||
token = (
|
token = (
|
||||||
await Notifications.getExpoPushTokenAsync({
|
await Notifications.getExpoPushTokenAsync({
|
||||||
projectId,
|
projectId,
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
console.log(token);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
token = `${e}`;
|
token = `${e}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert('Must use physical device for Push Notifications');
|
alert('Must use physical device for Push Notifications');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue