Skip to content

Latest commit

 

History

History
 
 

developer-motivator

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Get notified each time a new user open your app the first time or remove your app from his device.

This sample demonstrates how to send a Firebase Cloud Messaging (FCM) notification from a Analytics triggered Function.

Functions Code

See file functions/index.js for the code.

Sending the notification is done using the Firebase Admin SDK.

The dependencies are listed in functions/package.json.

Trigger rules

The functions triggers every time a new user open your app the first time or remove your app from his device.

Setup and test this sample section

To deploy and test the sample:

  • Create a Firebase project on the Firebase Console

  • Install the required dependencies by running npm install in the functions directory

  • Add this log to your android project:

    Log.d("Firebase", "token "+ FirebaseInstanceId.getInstance().getToken());
  • Run your app on your device and copy the device token from the android logcat

  • Set the dev_motivator.device_token Google Cloud environment variables. For this use:

    firebase functions:config:set dev_motivator.device_token="your_developer_device_token" 
  • Deploy your project's code using firebase deploy

  • You'll now get a notification on your mobile when a user opens your app for the first tie and when they uninstall your app.