Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shwetachauhan18/referralcodefirebase
For detail description
https://github.com/shwetachauhan18/referralcodefirebase
Last synced: 9 days ago
JSON representation
For detail description
- Host: GitHub
- URL: https://github.com/shwetachauhan18/referralcodefirebase
- Owner: ShwetaChauhan18
- Created: 2018-04-24T02:01:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-03T14:05:37.000Z (about 6 years ago)
- Last Synced: 2024-03-14T12:57:47.881Z (8 months ago)
- Language: Kotlin
- Homepage: https://firebase.google.com/docs/dynamic-links/use-cases/rewarded-referral
- Size: 138 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
"# ReferralCodeFirebase"
"# Firebase cloud function"
####Javascript```javascript
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);exports.grantSignupReward = functions.database.ref('/users/{uid}/last_signin_at')
.onCreate((snap,context) => {
const uid = context.params.uid;
admin.database().ref(`users/${uid}/referred_by`)
.once('value').then((data) => {
var referred_by_somebody = data.val();
if (referred_by_somebody) {
var moneyRef = admin.database().ref(`/users/${uid}/earned`);
moneyRef.transaction((current_value)=> {
return (current_value || 0) + 10;
});var moneyReferred=admin.database().ref(`/users/${referred_by_somebody}/earned`);
moneyReferred.transaction((current_value)=> {
return (current_value || 0) + 10;
});
}
return console.log('reddem updated')
//return Promise.resolve();
}).catch(error => {
console.log("Got an error: ",error);
});
});