Skip to content

Commit

Permalink
fixup! iOSの通知テスト
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakawaTakuya committed Jan 11, 2025
1 parent c5842ea commit b965149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const verifyAppCheckToken = async (
const appCheckToken = req.get("X-Firebase-AppCheck");

if (!appCheckToken) {
res
return res
.status(400)
.send({ message: "Authentication error: App Check token is missing." });
}
Expand All @@ -43,10 +43,10 @@ const verifyAppCheckToken = async (
.appCheck()
.verifyToken(appCheckToken as string);
console.log("Verified App Check Token:", decodedToken);
next();
return next();
} catch (error) {
logger.error(`Invalid App Check token with ${appCheckToken}:`, error);
res.status(401).send("Invalid App Check token.");
return res.status(401).send("Invalid App Check token.");
}
};

Expand All @@ -55,7 +55,7 @@ if (process.env.NODE_ENV === "production") {
app.use((req, res, next) => {
if (req.headers.token === process.env.NOTIFICATION_KEY) {
// tasksからの/notificationの場合はスキップ
next();
return next();
} else {
verifyAppCheckToken(req, res, next);
}
Expand Down
8 changes: 7 additions & 1 deletion src/app/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { showSnackBar } from "@/Components/SnackBar/SnackBar";
import { Analytics, getAnalytics } from "firebase/analytics";
import { initializeApp } from "firebase/app";
Expand Down Expand Up @@ -55,7 +56,7 @@ if (typeof window !== "undefined") {
isTokenAutoRefreshEnabled: true,
});

getToken(appCheck)
await getToken(appCheck)
.then((token) => {
console.log("App Check: Success");
appCheckToken = token.token;
Expand All @@ -68,6 +69,11 @@ if (typeof window !== "undefined") {
type: "warning",
});
});

showSnackBar({
message: `appCheckToken: ${appCheckToken}`,
type: "normal",
});
}
}

Expand Down

0 comments on commit b965149

Please sign in to comment.