Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix/delete-projectId : ProjectID 삭제 #208

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/config/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ export const getMyComments = () => {
return api.get("/members/comments");
};

export const createNotificationToken = (apnsToken, deviceId) => {
export const createNotificationToken = (pushToken, deviceId) => {
return api.post("/notifications/push", {
apnsToken,
pushToken,
deviceId,
});
};
Expand Down
31 changes: 16 additions & 15 deletions src/pages/login/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import IconNotSeePw from "@components/login/IconNotSeePw";
import IconSeePw from "@components/login/IconSeePw";
import DifeLine from "@components/common/DifeLine";
import InfoCircle from "@components/common/InfoCircle";
import Constants from "expo-constants";

const isMockLoginEnabled = process.env.EXPO_PUBLIC_MOCK_LOGIN === "true";
const mockEmail = process.env.EXPO_PUBLIC_MOCK_EMAIL || "";
Expand Down Expand Up @@ -82,23 +81,23 @@ const LoginPage = () => {
const handleLogin = async () => {
try {
const loginResponse = await login(emailRef.val, valuePW);
const { status } = await Notifications.requestPermissionsAsync();

const projectId =
Constants?.expoConfig?.extra?.eas?.projectId ??
Constants?.easConfig?.projectId;
if (!projectId) {
console.log("Project ID not found");
let token = "";
const { status: existingStatus } =
await Notifications.getPermissionsAsync();
let finalStatus = existingStatus;

if (existingStatus !== "granted") {
const { status } =
await Notifications.requestPermissionsAsync();
finalStatus = status;
}

let token = "";
if (status === "granted") {
token = (await Notifications.getExpoPushTokenAsync(projectId))
.data;
} else {
if (finalStatus !== "granted") {
token = "undefined";
console.log("Push notification permissions not granted");
} else {
token = (await Notifications.getExpoPushTokenAsync()).data;
}

const id = loginResponse.data.member_id;
const accessToken = loginResponse.data.accessToken;
const refreshToken = loginResponse.data.refreshToken;
Expand All @@ -124,7 +123,9 @@ const LoginPage = () => {
navigation.navigate("Nickname");
}

await createNotificationToken(token, deviceId);
if (token) {
await createNotificationToken(token, deviceId);
}
} catch (error) {
Sentry.captureException(error);
console.error(
Expand Down
Loading