Skip to content

Commit

Permalink
Removed userId from DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
theolli999 committed Sep 12, 2024
1 parent 00274f4 commit ecf22f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 12 additions & 4 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const prefix = Linking.createURL("/");
//https://medium.com/@arashfallahi1989/how-to-integrate-firebase-push-notification-in-react-native-expo-bd5cc694f181

export default function App() {

const checkVersion = async () => {
try {
const currentVersion = VersionCheck.getCurrentVersion();
Expand Down Expand Up @@ -72,7 +73,17 @@ export default function App() {
console.log(error);
}
};
async function fetchAndLogUser() {
try {
const user = await API.users.getMe();
console.log(user);
} catch (error) {
console.error('Error fetching user:', error);
}
}

// Anropa funktionen
fetchAndLogUser();
useEffect(() => {
checkVersion();

Expand All @@ -89,15 +100,13 @@ export default function App() {

// Get the token
const { data: expoPushToken } = await Notifications.getExpoPushTokenAsync();

if (expoPushToken) {
console.log("Your Expo push token is:", expoPushToken);

// Register the token with the backend
try {
const allRegister: RegisterUserDTO = {
Token: expoPushToken,
userId: (await API.users.getMe()).id.toString()
Token: expoPushToken
};
const allResponse = await API.expo.registerExpo(allRegister);
console.log(
Expand All @@ -116,7 +125,6 @@ export default function App() {
requestUserPermission();
}
}, []);

return (
<AppLoader>
<Fragment>
Expand Down
1 change: 0 additions & 1 deletion api/Expo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { post, postAuth } from "./_HttpHelpers";

export type RegisterUserDTO = {
Token: string;
userId: string;
};

export const registerExpo = async (dto: RegisterUserDTO): Promise<Response> => {
Expand Down

0 comments on commit ecf22f4

Please sign in to comment.