Skip to content

Commit

Permalink
test: fcm url test
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jun 3, 2024
1 parent be20767 commit 1da1a2c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ firebase.initializeApp({
self.addEventListener('push', function (event) {
if (event.data) {
console.log(event.data.json().data);
console.log(event.data.json().notification.body);
console.log(event.data.json().notification);

// 알림 메세지일 경우엔 event.data.json().notification;
const url = event.data.json().data;
const data = event.data.json().notification;
const options = {
body: data.body,
icon: data.image,
image: data.image,
data: {
click_action: data.click_action
click_action: data.click_action,
targetUrl: url.targetUrl
}
};

Expand All @@ -41,7 +43,7 @@ self.addEventListener('notificationclick', function (event) {

// 이동할 url
const urlToOpen = event.notification.data.targetUrl;

console.log(urlToOpen);
// 클라이언트에 해당 사이트가 열려 있는지 체크
const promiseChain = clients
.matchAll({
Expand Down

0 comments on commit 1da1a2c

Please sign in to comment.