Rev 182 |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
//import firebase from 'firebase';
export const inicializarFirebase = () => {
firebase.initializeApp({
messagingSenderId: '963735578116' // troque pelo seu sender id
});
navigator.serviceWorker
.register('https://leocardoso94.github.io/push-notification-demo/firebase-messaging-sw.js')
.then((registration) => {
firebase.messaging().useServiceWorker(registration);
}).catch(console.error);
}
export const pedirPermissaoParaReceberNotificacoes = async () => {
try {
const messaging = firebase.messaging();
await messaging.requestPermission();
const token = await messaging.getToken();
console.log('token do usuário: ', token);
return token;
} catch (error) {
console.error(error);
}
}
// WEBPACK FOOTER //
// ./src/push-notification.js