You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order for Firebase Cloud Messaging (FCM) to work, the user must first give permission.
So, after the user has signed in, they should be redirected to your new "Messaging" page. Here, you will make a clean/simple UI where you'll inform the user that these browser notifications will be really useful in letting you know your turn is here, etc.
**If the user declines or any error pops up, the token should be saved as "NULL"!
The following snippet will guide you through using Firebase messages:
Then, once permission is granted, FCM will generate a unique registration token that represents the user’s device or browser instance. We will use this token later on to send messages.
NOTE: The VAPID_KEY is available on the dashboard. I have also listed it here:
const getFcmToken = async () => {
try {
const token = await getToken(messaging, { vapidKey: 'YOUR_PUBLIC_VAPID_KEY' });
if (token) {
console.log('FCM token:', token);
// TODO! - Save to react context / local storage
} else {
console.error('Failed to get FCM token.');
}
} catch (error) {
console.error('Error getting FCM token:', error);
}
};
getFcmToken();
Now, modify the react context to include a token property as well. Then, once the token has been retrieved, you must save it to the context/local storage.
The text was updated successfully, but these errors were encountered:
Ron-Madan
changed the title
FE - 1: User Messaging Permission
FE - 1.25: User Messaging Permission
Jan 15, 2025
In order for Firebase Cloud Messaging (FCM) to work, the user must first give permission.
So, after the user has signed in, they should be redirected to your new "Messaging" page. Here, you will make a clean/simple UI where you'll inform the user that these browser notifications will be really useful in letting you know your turn is here, etc.
**If the user declines or any error pops up, the token should be saved as "NULL"!
The following snippet will guide you through using Firebase messages:
Then, once permission is granted, FCM will generate a unique registration token that represents the user’s device or browser instance. We will use this token later on to send messages.
NOTE: The VAPID_KEY is available on the dashboard. I have also listed it here:
BIn7HfgGhmz1NJ7T0SOYcxQC1MkNjRlwT4awKTSJp9yvruJFZxzShp4reOdk1kpeKO6CRI2d68F0X_Dr1zrhfSI
Now, modify the react context to include a token property as well. Then, once the token has been retrieved, you must save it to the context/local storage.
The text was updated successfully, but these errors were encountered: