text: const authorization = require('./constant').notifyService.authorization;
  const url = require('./constant').notifyService.url;
  const alert = 'You got a meesage';
  const sound = 'bingbong.aiff';
  const request = require('request');
  const Device = require('../models/device');
  const User = require('../models/user');
  
  const setOptions = (body) => ({
      headers: {
          'Content-type': 'application/json',
          'Authorization': authorization
      },
      url,
      body: JSON.stringify(body)
  })
  
  const push = (body) => {
      const options = setOptions(body)
      return new Promise((resolve, reject) => {
          request.post(options, err => {
              if (err) {
                  return resolve(err);
              }
              resolve({})
          })
      })
  }
  
  const pushNotify = async (tokens, data, next) => {
      try {
          const input = {
              notification: data,
              data: data,
              registration_ids: tokens
          }
  
          await push(input);
      }
      catch (err) {
          console.log(err);
          next(err);
      }
  }
  
  module.exports = {
      pushNotify
  }
  
  