You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Eric Gilmore
7ec5899b73
|
8 years ago | |
---|---|---|
.. | ||
functions | 8 years ago | |
README.md | 8 years ago | |
firebase.json | 8 years ago |
README.md
Send a coupon via FCM to users who have completed a purchase
This sample shows how to send a coupon to your users who have just purchased something. For instance: 10% off on your next purchase!
Functions Code
See file functions/index.js for the trigger and the FCM code.
The function assumes that you are setting the Firebase Analytics User ID to be the same as the Firebase Auth uid using the setUserId API. Also it is assumed that the FCM Device Tokens need to be saved in the Firebase Realtime Database under /users/$uid/tokens
.
The dependencies are listed in functions/package.json.
Trigger rules
The function triggers on changes to in_app_purchase
Firebase Analytics events. For other automatically logged events see: https://support.google.com/firebase/answer/6317485
Deploy and test
This sample can be tested on your Android and iOS app. To test it out:
- Set the project to your Firebase project using
firebase use --add
then select your projec tin the list. - Deploy your project using
firebase deploy
- Make your app crash (somehow).
- Within a few hours the coupon will be sent by an FCM notification.