Google Cloud Messaging for React Native
Just last week, at Google I/O, Google announced Google Cloud Messaging for iOS.
Relaying on the official Google Cloud Messaging Pod, Christian Sullivan is now offering its full capability to all React Native developers out there.
react-native-gcm on GitHub
Usage
// Register for Push Notifications
gcm.register()
// Subscribe to topic
gcm.topicSubscribe('/topics/test', (err, res) => {});
// Unsubscribe from topic
gcm.topicUnsubscribe('/topics/test', (err, res) => {});
// Send upstream message
gcm.sendMessage({
id: '' // unique message id
to: '', // recip id
ttl: 500 // optional time to live
message: {}, // msg data
});
GCM has all "EventEmitter" methods
// Connected to GCM socket
gcm.on("connection", (res) => {});
// Disconnected from GCM socket
gcm.on("disconnect", (res) => {});
// Client registered with gcm
gcm.on("registeredClient", (res) => {});
// Application entered background
gcm.on("enteredBackground", (res) => {});
// Application became active again
gcm.on("becameActive", (res) => {});
// Received message from GCM
gcm.on("message", (res) => {});