Created
March 23, 2017 03:35
-
-
Save tjkang/1723d4679680b4b65b1bcf2c5ab841e0 to your computer and use it in GitHub Desktop.
Sending a push notification from the RN App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_onPress = () => { | |
const subjectsRef = firebase.database().ref('subjects'); | |
const notificationReqsRef = firebase.database().ref('notificationRequests'); | |
const subjectData = { | |
author: 'TJ', | |
title: this.state.subjectText, | |
}; | |
const notificationReq = { | |
from_username: 'TJ', | |
message: `just posted new topic "${this.state.topicText}"`, | |
}; | |
const newSubjectKey = subjectsRef.push().key; | |
const newNotificationReqKey = notificationReqsRef.push().key; | |
const updates = {}; | |
updates[`/topics/${newSubjectKey}`] = subjectData; | |
updates[`/notificationRequests/${newNotificationReqKey}`] = notificationReq; | |
firebase.database().ref().update(updates); | |
this.setState({ | |
subjectText: '', | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment