Skip to content

Commit

Permalink
Merge pull request #70 from ISTTP/develop
Browse files Browse the repository at this point in the history
ios fcm 보류
  • Loading branch information
kyr4601 authored Jul 29, 2024
2 parents 2cc7402 + 3d00547 commit b46d159
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions apps/client/src/firebase-messaging-sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ const firebaseConfig = {

firebase.initializeApp(firebaseConfig);

const messaging = firebase.messaging();
//const messaging = firebase.messaging();
let messaging: firebase.messaging.Messaging | null = null;
if (firebase.messaging.isSupported()) {
messaging = firebase.messaging();
}


export function requestPermission() {
if (!messaging) { return console.log('ios') }
Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
registerServiceWorker();
Expand All @@ -38,8 +44,7 @@ function registerServiceWorker() {
}

export function getFcmToken() {
messaging
.getToken({ vapidKey: process.env.FIREBASE_VAPID_KEY })
messaging?.getToken({ vapidKey: process.env.FIREBASE_VAPID_KEY })
.then((token: string) => {
sendToken(token);
})
Expand Down

0 comments on commit b46d159

Please sign in to comment.