1) 포그라운드 푸시알림 처리2) 백그라운드 푸시알림 처리과제 푸시알림 연동포럼 푸시알림 연동3) 알림 형식 정의과제 알림 형식포럼 알림 형식node.js 메세지 송신 테스트 소스코드
1) 포그라운드 푸시알림 처리

과제, 포럼 알림 개수 별도관리

탭 클릭 시 알림개수 초기화

탭 클릭 시 알림개수 초기화
2) 백그라운드 푸시알림 처리
과제 푸시알림 연동

포럼 푸시알림 연동

3) 알림 형식 정의
과제 알림 형식
notification: { title: "새로운 과제가 등록되었습니다!", body: "Title: React 조사", }, data: { assignId, },
포럼 알림 형식
notification: { title: "새로운 댓글이 등록됐습니다!", body: "Title: React 조사", }, data: { courseId, forumId, },
node.js 메세지 송신 테스트 소스코드
const { response } = require("express"); const express = require("express"); const router = express.Router(); var admin = require("firebase-admin"); var serviceAccount = require("/Users/night-ohl/Desktop/develop/nodeEnv/opstech-fcm-90mobile.json"); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), }); /** * 포럼 : http://ip/student/courseforum/post/${courseId}/${forumId} * 과제 : http://ip/student/assignment/${assignId} */ router.get("/personal", (req, res, next) => { const registrationToken = [ "---------", // android "---------", // ios ]; const assignId = (3).toString(); const courseId = (2).toString(); const forumId = (5).toString(); const payload = { newAssignment: { notification: { title: "새로운 과제가 등록되었습니다!", body: "Title: React 조사", }, data: { assignId, }, }, newFeedback: { notification: { title: "새로운 피드백이 등록됐습니다!", body: "Title: React 조사", }, data: { assignId, }, }, newComment: { notification: { title: "새로운 댓글이 등록됐습니다!", body: "Title: React 조사", }, data: { courseId, forumId, }, }, newResolve: { notification: { title: "답변이 채택되었습니다!", body: "Title: React 조사", }, data: { courseId, forumId, }, }, }; const notshow_payload = { data: { hi: "hello", }, }; admin .messaging() .sendToDevice(registrationToken, payload.newComment, { // Required for background/quit data-only messages on iOS contentAvailable: true, // Required for background/quit data-only messages on Android priority: "high", }) .then((response) => { console.log("Successfully sent message:", response); }) .catch((error) => { console.log("Error sending message:", error); }); res.send("Push-Noti 테스트 완료"); }); module.exports = router;