Giter Club home page Giter Club logo

scm's Introduction

SCM - SCMessaging

https://i.imgur.com/wyb0Vv7.png

Download Build Status

SCM - Socket Cloud Messaging for Android | Socket.IO

Android push notification service based on io-session-handler

Building an own Android push messaging service to receive data messages in the background in real-time and alternate for Firebase Cloud Messaging.

Initialization

Add the below dependency into your module level build.gradle file

implementation 'com.aslam:scm:+'

Make sure you have set usesCleartextTraffic to true in AndroidManifest.xml file

<application
    ...
    android:usesCleartextTraffic="true">

Simple Usage

Create a SCMessaging instance with context, socket server url and device token.

SCMessaging scMessaging = new SCMessaging(this, "http://192.168.8.200:3000", "user_token");

Implement onMessageData method to listen the server push messages.

scMessaging.setListener(new SCMessaging.Listener() {
    @Override
    public void onMessageData(String data) {
        Log.d("onMessageData", data);
    }
});

Finally call the connect method to start the socket connection.

scMessaging.connect();

Advanced Usage

Override all the methods in SCMessaging.Listener() to notify the program from more events as below.

scMessaging.setListener(new SCMessaging.Listener() {

    @Override
    public void onMessageData(String data) {

    }

    @Override
    public void onConnect(String serverURL) {

    }

    @Override
    public void onDisconnect(String serverURL) {

    }

    @Override
    public void onConnectError(Exception ex) {

    }
});

More Options

This is the constructor for passing more options to the Socket.IO engine, the options variable should be an IO.Options() object, if it's not included in your project, you can add the library in the build.gradle file.

IO.Options options = new IO.Options();
options.reconnection = false;
SCMessaging scMessaging = new SCMessaging(this, "http://192.168.8.200:3000", "user_token", options);
implementation ('io.socket:socket.io-client:1.0.0') {
    exclude group: 'org.json', module: 'json'
}

Demonstration

Screenshot

Test the sample app that I made for you: SCM-Demo-v1.0.1.apk


Made with ❤️ by Aslam Anver

scm's People

Contributors

aslamanver avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.