Skip to content

Conversation

tidoemanuele
Copy link
Contributor

@tidoemanuele tidoemanuele commented May 12, 2017

Send Firebase Cloud Messaging each time a new user open your app the first time or remove your app from his device.

@puf
Copy link
Contributor

puf commented May 12, 2017

I had to laugh at the concept of this sample. :-)

@cliffhall
Copy link

Not a bad idea

Copy link
Contributor

@nicolasgarnier nicolasgarnier left a 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
Copy link
Contributor

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" }
Copy link
Contributor

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';
Copy link
Contributor

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 => {
Copy link
Contributor

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 => {
Copy link
Contributor

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 => {
Copy link
Contributor

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 => {
Copy link
Contributor

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?

@@ -0,0 +1,8 @@
{
"database": {
Copy link
Contributor

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 @@
{
Copy link
Contributor

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.
Copy link
Contributor

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.

@nicolasgarnier
Copy link
Contributor

Nice thanks!

Could you add an entry to the main README.md (at the root) pointing to your sample and we should be good :)

@nicolasgarnier
Copy link
Contributor

All right looks good @tidoemanuele ! thanks!

@nicolasgarnier nicolasgarnier merged commit 30a8049 into firebase:master Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants