Created
April 13, 2019 17:20
-
-
Save Eder87rh/257f49de144193d7511d4ae61556b055 to your computer and use it in GitHub Desktop.
5 -cropchien - createDog - index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exports.createDog = functions.firestore | |
| .document('dogs/{dogId}') | |
| .onCreate(event => { | |
| var dog = event.data(); | |
| console.log(dog.comment); | |
| axios.post(`https://fcm.googleapis.com/fcm/send`,{ | |
| "to" : "/topics/general", | |
| "priority" : "high", | |
| "notification" : { | |
| "title" : "Nueva publicación", | |
| "body" : dog.comment, | |
| "click_action":"http://localhost:8081", | |
| "icon":"http://localhost:8081/chrome/chrome-installprocess-128-128.png", | |
| }, | |
| },{ | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Authorization': `key=${serverKey}` | |
| }, | |
| }).then((response) => { | |
| console.log(response); | |
| console.log(response.data); | |
| }) | |
| .catch(err => { | |
| console.log(err.response); | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment