rnr
react-native-realtime-pusher
npm i react-native-realtime-pusher
rnr

react-native-realtime-pusher

A Pusher module for React Native

by Joe Leonard

1.3.0 (see all)License:MITTypeScript:Not Found
npm i react-native-realtime-pusher
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:

include ':Pusher'
project(':Pusher').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-realtime-pusher/android')

In build.gradle add the following line:

compile project(':Pusher')

In MainApplication.java add the following lines:

import com.gijoehosaphat.pusher.PusherPackage;
new PusherPackage()

Example usage:

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')
}

Downloads/wk

1

GitHub Stars

20

LAST COMMIT

5yrs ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.3.0
latest
5yrs ago
No alternatives found
No tutorials found
Add a tutorial