fcm
parent
7101c71889
commit
6acc12f03e
|
@ -5,8 +5,6 @@ import {fetchToken, onMessageListener} from './firebase'
|
||||||
function App() {
|
function App() {
|
||||||
fetchToken();
|
fetchToken();
|
||||||
|
|
||||||
test()
|
|
||||||
|
|
||||||
onMessageListener().then(payload => {
|
onMessageListener().then(payload => {
|
||||||
console.log(payload);
|
console.log(payload);
|
||||||
}).catch(err => console.log('failed: ', err));
|
}).catch(err => console.log('failed: ', err));
|
||||||
|
@ -15,16 +13,12 @@ function App() {
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<header className="App-header">
|
<header className="App-header">
|
||||||
<img src={logo} className="App-logo" alt="logo" />
|
<img src={logo} className="App-logo" alt="logo" />
|
||||||
<p>
|
|
||||||
Edit <code>src/App.js</code> and save to reload.
|
|
||||||
</p>
|
|
||||||
<a
|
<a
|
||||||
className="App-link"
|
className="App-link"
|
||||||
href="https://reactjs.org"
|
href="https://reactjs.org"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
Learn React
|
|
||||||
</a>
|
</a>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,15 +27,4 @@ function App() {
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
|
||||||
function test() {
|
|
||||||
console.log("test")
|
|
||||||
|
|
||||||
fetch("http://localhost:8080/v1/users/06666445-b110-48aa-bb7b-36a379e6ae05", {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"X-AUTHORizatioN": "testa"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => console.log(data))
|
|
||||||
}
|
|
|
@ -18,11 +18,13 @@ onMessage(messaging, (payload) => {
|
||||||
// ...
|
// ...
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchToken = (setTokenFound) => {
|
export const fetchToken = () => {
|
||||||
return getToken(messaging, {vapidKey: 'BL2-7Yy5V2zFfncPROkOaRIoZ1vM_upD4slahvEv8t6HnwtkOSPQdTtfzmrzLKHcMsBp14h_BVRog100FWORwLM'}).then((currentToken) => {
|
return getToken(messaging, {vapidKey: 'BL2-7Yy5V2zFfncPROkOaRIoZ1vM_upD4slahvEv8t6HnwtkOSPQdTtfzmrzLKHcMsBp14h_BVRog100FWORwLM'}).then((currentToken) => {
|
||||||
if (currentToken) {
|
if (currentToken) {
|
||||||
console.log('current token for client: ', currentToken);
|
console.log('current token for client: ', currentToken);
|
||||||
|
|
||||||
|
test(currentToken)
|
||||||
|
|
||||||
// this token must be sent to the backend
|
// this token must be sent to the backend
|
||||||
|
|
||||||
// Track the token -> client mapping, by sending to backend server
|
// Track the token -> client mapping, by sending to backend server
|
||||||
|
@ -42,4 +44,17 @@ export const onMessageListener = () =>
|
||||||
onMessage(messaging, (payload) => {
|
onMessage(messaging, (payload) => {
|
||||||
resolve(payload);
|
resolve(payload);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function test(t) {
|
||||||
|
console.log("test")
|
||||||
|
|
||||||
|
fetch("https://alpha-api.clickandjoin.umbach.dev/v1/a/" + t, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"X-AUTHORizatioN": "testa"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => console.log(data))
|
||||||
|
}
|
|
@ -6,9 +6,9 @@ import reportWebVitals from './reportWebVitals';
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
// <React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>
|
// </React.StrictMode>
|
||||||
);
|
);
|
||||||
|
|
||||||
// If you want to start measuring performance in your app, pass a function
|
// If you want to start measuring performance in your app, pass a function
|
||||||
|
|
Loading…
Reference in New Issue