import 'typeface-roboto'; import React from 'react'; import ReactDOM from 'react-dom'; import { HashRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import App from './App'; import * as serviceWorker from './serviceWorker'; import store from './store'; ReactDOM.render(( ), document.getElementById('root')); window.updateNotificationToken = async (token) => { // Get user attributes const response = await fetch('/api/session', { headers: { Accept: 'application/json' } }); if (response.ok) { let user = await response.json(); if (user.attributes) { if (!user.attributes.notificationTokens || user.attributes.notificationTokens.indexOf(token) < 0) { if (!user.attributes.notificationTokens) { user.attributes.notificationTokens = token; } else { user.attributes.notificationTokens += ',' + token; } // Set user attributes const response2 = await fetch(`/api/users/${user.id}`, { method: 'PUT', headers: { Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(user), }); console.log ('Set token: ', await response2.json()); } } } } serviceWorker.unregister();