10000 Merge commit 'c159296556d66b876e7b49dcb8bdf55cdabe5a89' into HEAD · sengbh/quickstart-js@0219a88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0219a88

Browse files
author
devrel-build
committed
Merge commit 'c159296556d66b876e7b49dcb8bdf55cdabe5a89' into HEAD
2 parents cdba99a + c159296 commit 0219a88

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

auth/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-->
1717
<html>
1818
<head>
19-
<meta charset=utf-8/>
19+
<meta charset=utf-8 />
2020
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2121
<title>Firebase Authentication Example</title>
2222

messaging/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,34 @@ Content-Type: application/json
4646
}
4747
```
4848

49+
### Fetch
50+
```js
51+
var key = 'YOUR-SERVER-KEY';
52+
var to = 'YOUR-IID-TOKEN';
53+
var notification = {
54+
'title': 'Portugal vs. Denmark',
55+
'body': '5 to 1',
56+
'icon': 'firebase-logo.png',
57+
'click_action': 'http://localhost:8081'
58+
};
59+
60+
fetch('https://fcm.googleapis.com/fcm/send', {
61+
'method': 'POST',
62+
'headers': {
63+
'Authorization': 'key=' + key,
64+
'Content-Type': 'application/json'
65+
},
66+
'body': JSON.stringify({
67+
'notification': notification,
68+
'to': to
69+
})
70+
}).then(function(response) {
71+
console.log(response);
72+
}).catch(function(error) {
73+
console.error(error);
74+
})
75+
```
76+
4977
### cURL
5078
```
5179
curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type: application/json" -d '{

messaging/index.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-->
1717
<html>
1818
<head>
19-
<meta charset=utf-8/>
19+
<meta charset=utf-8 />
2020
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2121
<title>Firebase Cloud Messaging Example</title>
2222

@@ -186,11 +186,7 @@ <h4>Needs Permission</h4>
186186
}
187187

188188
function setTokenSentToServer(sent) {
189-
if (sent) {
190-
window.localStorage.setItem('sentToServer', 1);
191-
} else {
192-
window.localStorage.setItem('sentToServer', 0);
193-
}
189+
window.localStorage.setItem('sentToServer', sent ? 1 : 0);
194190
}
195191

196192
function showHideDiv(divId, show) {

0 commit comments

Comments
 (0)
0