Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gijoehosaphat/react-native-realtime-pusher
A Pusher module for React Native
https://github.com/gijoehosaphat/react-native-realtime-pusher
Last synced: 5 days ago
JSON representation
A Pusher module for React Native
- Host: GitHub
- URL: https://github.com/gijoehosaphat/react-native-realtime-pusher
- Owner: gijoehosaphat
- Created: 2016-03-25T19:08:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-01T20:58:58.000Z (about 7 years ago)
- Last Synced: 2024-11-09T07:14:51.916Z (about 1 month ago)
- Language: Objective-C
- Size: 124 KB
- Stars: 21
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native - react-native-realtime-pusher ★19 - React Native module implementing the Pusher Realtime API (Components / Integrations)
- awesome-react-native - react-native-realtime-pusher ★19 - React Native module implementing the Pusher Realtime API (Components / Integrations)
- awesome-react-native - react-native-realtime-pusher ★19 - React Native module implementing the Pusher Realtime API (Components / Integrations)
- awesome-react-native-ui - react-native-realtime-pusher ★5 - React Native module implementing the Pusher Realtime API (Components / Integrations)
- awesome-react-native - react-native-realtime-pusher ★19 - React Native module implementing the Pusher Realtime API (Components / Integrations)
README
# react-native-realtime-pusher
Implementing the Pusher Realtime API for Android and iOS.## Installation Android ##
`yarn add react-native-realtime-pusher`
### In `settings.gradle` add the following lines:
```groovy
include ':Pusher'
project(':Pusher').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-realtime-pusher/android')
```### In `build.gradle` add the following line:
```groovy
compile project(':Pusher')
```### In `MainApplication.java` add the following lines:
```java
import com.gijoehosaphat.pusher.PusherPackage;
``````java
new PusherPackage()
```# Example usage:
```javascript
import Pusher from 'react-native-realtime-pusher'
...
// These values determined by *your* setup on *your* backend.
// hostname ~= http://myserver.com
// authPath ~= /auth
// channelPath ~= /channel
Pusher.initialize(hostname, authPath, channelPath, appKey, cluster, token) //This is a Promise
...
//Connect (There is also disconnect)
Pusher.connect() //This is a Promise
...
//Subscribe to a channel (There is also channelUnsubscribe)
Pusher.channelSubscribe(channel, channelEventName) //This is a Promise
...
//Send a message
Pusher.messagePost(messageObject, channelName, channelEvent) //This is a promise
...
//You will want to listen for events:
componentDidMount() {
DeviceEventEmitter.addListener('pusher-event', this.yourEventHandler)
}
componentWillUnmount() {
DeviceEventEmitter.removeAllListeners('pusher-event')
}
```