Android Pusher

Android library for pusher.com

License

License

GroupId

GroupId

com.github.kevinsawicki
ArtifactId

ArtifactId

android-pusher
Last Version

Last Version

0.6
Release Date

Release Date

Type

Type

jar
Description

Description

Android Pusher
Android library for pusher.com
Project URL

Project URL

https://github.com/kevinsawicki/Android_Pusher
Source Code Management

Source Code Management

https://github.com/kevinsawicki/Android_Pusher

Download android-pusher

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.kevinsawicki/android-pusher/ -->
<dependency>
    <groupId>com.github.kevinsawicki</groupId>
    <artifactId>android-pusher</artifactId>
    <version>0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.kevinsawicki/android-pusher/
implementation 'com.github.kevinsawicki:android-pusher:0.6'
// https://jarcasting.com/artifacts/com.github.kevinsawicki/android-pusher/
implementation ("com.github.kevinsawicki:android-pusher:0.6")
'com.github.kevinsawicki:android-pusher:jar:0.6'
<dependency org="com.github.kevinsawicki" name="android-pusher" rev="0.6">
  <artifact name="android-pusher" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.kevinsawicki', module='android-pusher', version='0.6')
)
libraryDependencies += "com.github.kevinsawicki" % "android-pusher" % "0.6"
[com.github.kevinsawicki/android-pusher "0.6"]

Dependencies

provided (1)

Group / Artifact Type Version
android » android jar 1.6_r3

Project Modules

There are no modules declared in this project.

Android_Pusher

This code provides a simple implementation allowing for an Android 1.6+ app to receive realtime events from http://pusher.com

This project makes use of a slightly modified Weberknect, available at http://v.google.com/p/weberknecht/

Special thanks to http://natronbaxter.com/ and http://mokasocial.com for giving me the opportunity to write and open source this!

This project is under the Apache License, Version 2.0! http://www.apache.org/licenses/LICENSE-2.0.html

To get started receiving events from your Pusher account:

  • Clone this repository locally
  • Sign up for an account at http://pusher.com
  • Download Eclipse and the Android SDK from http://developer.android.com/sdk/index.html
  • Open the project in Eclipse (Using File > New Project > From Existing Source)
  • Open PusherSampleActivity.java, and find the constants PUSHER_APP_KEY and PUSHER_CHANNEL_1
  • Change these constants to your assigned Pusher app key and your first channel.
  • Run the application on a device or emulator, and send messages from your Pusher console.
  • To add more channels, duplicate the existing code that handles inbound.
  • To handle multiple event types, modify the Activity's mHandler.handleMessage() function, checking the "type" string of the incoming event.

Quick Example of the new API:

Pusher pusher = new Pusher( "pusher_key" );
final Channel channel = pusher.subscribe( "chat-channel" );
channel.bind( "new_message" , new PusherCallback() {
  public void onEvent(JSONObject eventData) {
    Log.d( "Pusher", "Received " + eventData.toString() + " for event 'new_message' on channel " + channel.name );
    myTextField.setText( eventData.getString("content") );
  }
});

you can bind to any event of a channel as long as you are subscribed to it:

channel.bindAll(new PusherCallback() {
  public void onEvent(String eventName, JSONObject eventData) {
    Log.d( "Pusher", "Received " + eventData.toString() + " for event '" + eventName +"' on channel " + channel.name );
  }
});

bind() and bindAll() also work on the pusher instance, in order to retrieve events from all channels

pusher.bindAll(new PusherCallback() {
  public void onEvent(String eventName, JSONObject eventData) {
    Log.d( "Pusher", "I will show up on any event on any subscribed channel" );
  }
});

For support, visit http://pusher.com/support.

Versions

Version
0.6
0.5
0.4
0.3
0.2
0.1