socket.io-push-client

socket.io-push client by xuduo

Usage no npm install needed!

<script type="module">
  import socketIoPushClient from 'https://cdn.skypack.dev/socket.io-push-client';
</script>

README

node 依赖

npm install socket.io-push-client --save

js sdk

source

minified

初始化

var pushClient = PushClient('https://spush.yy.com', {
            transports: ['websocket'], //使用的tranport, proxy如果是多进程模式, 不支持polling
            useNotification: true //是否接收notification
        });

获取pushId

var pushId = pushClient.pushId

subscribe topic

var topic = 'topic';
pushClient.subscribeTopic(topic);
pushClient.unsubscribeTopic(topic);

push callback

pushClient.on('push',function(data){

});

notification callback

pushClient.on('notification',function(notification){
  console.log('',notification.title,notification.message,notification.payload);
});

connect callback

pushClient.on('connect',function(data){
  console.log('',data.uid);
});

pushClient.on('disconnect',function(){

});