npm install socket.io-push-client --save
source
minified
var pushClient = PushClient('https://spush.yy.com', {
transports: ['websocket'], //使用的tranport, proxy如果是多进程模式, 不支持polling
useNotification: true //是否接收notification
});
var pushId = pushClient.pushId
var topic = 'topic';
pushClient.subscribeTopic(topic);
pushClient.unsubscribeTopic(topic);
pushClient.on('push',function(data){
});
pushClient.on('notification',function(notification){
console.log('',notification.title,notification.message,notification.payload);
});
pushClient.on('connect',function(data){
console.log('',data.uid);
});
pushClient.on('disconnect',function(){
});