Closed felipe-augusto closed 4 years ago
por no model de user:
devices: [{ phone: 'Iphone 10', // can be extracted from user-agent, token: '', // string deviceId: '' // string }]
Criar metodos no user:
Model.addDevice(device => { this.devices = _.uniqBy([...this.devices, device], { deviceId: 'deviceId' }) }) Model.removeDevice(device => { this.devices = _.removeBy(this.devices, { deviceId: 'deviceId' }) }) Model.sendNotification(title, message) { const tokens = _.map(this.devices, 'token') // ver que biblioteca usa e como diabos manda notificação fcmWhatever.sendNotification(title, message, tokens) }
Criar duas rotas:
POST /users/me/devices => Model.addDevice DELETE /useres/me/devices/deviceID => Model.removeDevice
chamar o .save() retornar this.devices
this.devices
por no model de user:
Criar metodos no user:
Criar duas rotas:
POST /users/me/devices => Model.addDevice DELETE /useres/me/devices/deviceID => Model.removeDevice
chamar o .save() retornar
this.devices