cordova-plugin-socket-service

0.2.8 • Public • Published

cordova-plugin-socket-service

Cordova plugin for Socket.io sdk


how to use

Import : declare var SocketService: any;

/*******************/

let url_notif = '......';

Starting the service:

    SocketService.startService(this.url_notif,args0,args1, (data) => {
            console.log('SocketService OK ',data);
        },
        (err) => {
        console.log('SocketService eRR ',err);
        }
    );

Stopping the service:

    SocketService.stopService();

Listeners

Listeners listen for incoming messages in the background service. If the application is in the foreground when the message comes in, the message is broadcasted to Cordova and recieved by the listener.

Adding a listener:

 
    SocketService.addEventListener("incoming.event", (data) => {
        console.log("incoming.event",data); 
    });

Sending a message

    SocketService.fireNativeEvent( 'outgoing.event',
        {
        event: "register",
        data: {}
        }
    );

Wake-up functionality

If the application is in the background, or killed, when the message comes in, then the background service will show a popup notification. Clicking the notification will start the application. Once the application is started again, check that it was started by the background service:

  SocketService.hasParam("data", (data) => {
        console.log("hasParam event",data);
    });

And receive the incoming message:

    SocketService.getParam("data", (data) => {
        console.log("getParam event",JSON.parse(data));
    });

how to build for ionic

ionic cordova plugin add cordova-plugin-socket-service
 
ionic cordova build android

/cordova-plugin-socket-service/

    Package Sidebar

    Install

    npm i cordova-plugin-socket-service

    Weekly Downloads

    1

    Version

    0.2.8

    License

    ISC

    Unpacked Size

    88.1 kB

    Total Files

    19

    Last publish

    Collaborators

    • zghal