- Notifications
You must be signed in to change notification settings - Fork 3.9k
added developer motivator sample #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I had to laugh at the concept of this sample. :-) |
Not a bad idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tidoemanuele let;s go with it ;) Some comments though :)
"dependencies": { | ||
"firebase-admin": "^4.1.2", | ||
"firebase-functions": "^0.5.1" } | ||
} No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line at the end of file please :)
"description": "A simple developer motivator using Cloud Function and firebase analytics", | ||
"dependencies": { | ||
"firebase-admin": "^4.1.2", | ||
"firebase-functions": "^0.5.1" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line break before the }
@@ -0,0 +1,52 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add an Apache 2.0 Google licence header at the top of the file (see other similar files)
} | ||
}; | ||
| ||
admin.messaging().sendToDevice("put_your_developer_device_token_here", payload).then(response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the whole .then(...);
section since this in order to remove the invalid/expired device tokens from the database (here we don't use the database to hold device tokens).
} | ||
}; | ||
| ||
admin.messaging().sendToDevice("put_your_developer_device_token_here", payload).then(response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the whole .then(...);
section since this in order to remove the invalid/expired device tokens from the database (here we don't use the database to hold device tokens).
const functions = require('firebase-functions'); | ||
admin.initializeApp(functions.config().firebase); | ||
| ||
exports.appinstalled = functions.analytics.event('first_open').onLog(event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some short comment explaining what the functions does?
}); | ||
}); | ||
| ||
exports.appremoved = functions.analytics.event('app_remove').onLog(event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some short comment explaining what the functions does?
developer-motivator/firebase.json Outdated
@@ -0,0 +1,8 @@ | |||
{ | |||
"database": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can just be {}
since there is no database or hosting used.
@@ -0,0 +1,6 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just remove this file since we don't use the database in this sample.
| ||
## Trigger rules | ||
| ||
The functions triggers every time a new user open your app the first time or remove your app from his device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a ## Setup and test this sample
section giving a step by step process to follow in order to get the sample running, for instance the tricky part will be how to get a developper device token.
Nice thanks! Could you add an entry to the main README.md (at the root) pointing to your sample and we should be good :) |
All right looks good @tidoemanuele ! thanks! |
Send Firebase Cloud Messaging each time a new user open your app the first time or remove your app from his device.