npm i --save @appdevshop/push-service-client
Import package
import pushService from '@appdevshop/push-service-client'
Initialize client with information about where push-service is running.
After that you can use your pushService everywhere.
pushService.initialize({ host: 'localhost', port: 1343 })
You can register firebase token and connect it to some user.
pushService.register(userToken, firebaseToken)
You can unregister firebase token from some user.
pushService.unregister(userToken, firebaseToken)
You can send message to some user, using userToken
that was use while registering.
pushService.send(userToken, {
title: 'push title',
body: 'push text',
payload: {
field: 'all addditional info'
}
})
userToken
- some user identificator, string
firebaseToken
- firebase token that was send by user and generated by firebase
Or you can create multiple clients for each service:
const client1 = pushService.createClient({ host: 'localhost', port: 8081 })
const client2 = pushService.createClient({ host: 'localhost', port: 8082 })