This is a quick example of getting PubNub running in a React Native project.
react-native init ReactPubNub
npm install
Modify index.android.js
and index.ios.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import PubNub from 'pubnub'
class ReactPubNub extends Component {
render() {
return (
);
}
}
const pubnub = new PubNub({
subscribeKey: "demo",
publishKey: "demo",
ssl: true
})
pubnub.addListener({
message: function(message) {
console.log(message);
// handle message
}
})
pubnub.subscribe({
channels: ['girish']
});
AppRegistry.registerComponent('ReactPubNub', () => ReactPubNub);
react-native log-android