README
health-check | circle-ci | travis-ci | npm-version |
---|---|---|---|
notification lib
Library to receive notifications from notification-api.
install
npm
npm i solinftec-notification-lib --save
cdn
<!-- versioned -->
<script src='https://solinftec-notify.s3-sa-east-1.amazonaws.com/script/X.X.X/notification.min.js'></script>
<!-- last -->
<script src='https://solinftec-notify.s3-sa-east-1.amazonaws.com/script/last/notification.min.js'></script>
import
node
import Notification from 'solinftec-notification-lib';
react-native
import Notification from 'solinftec-notification-lib/react-native';
define options
const options =
{
show_log?:boolean, //to show log (default is false)
multiple_subscribe?:boolean, //to do multiples subscribes in same channel (default is false)
url?:string //to set other url (default is prd url)
};
init
const notification_lib = new Notification('app-key', 'server', 'token', options?);
using
setting a function to a specific channel
notification_lib.subscribe('channel_name', (notification) =>
{
//do something with the notification
});
setting a source of function by channel
let source_map =
[
{
'channel':'channel_a'
'callback': (notification) =>
{
//do something with the notification
}
}
,
{
'channel':'channel_b'
'callback': (notification) =>
{
//do something with the notification
}
}
];
notification_lib.setSourceOfFunctionByChannel(source_map);