<commit_before>var apn = require('apn');
var util = require('util');
var BasePushNotification = require('./BasePushNotification');
connection = new apn.Connection({
  cert: '',
  key: ''
}).on('error', console.log.bind(console.log)).on('transmissionError', console.log.bind(console.log));

util.inherits(APNPushNotification, BasePushNotification);

/**
 * Create new APN Push Notification
 * @param {Object} options
 * @returns {APNPushNotification}
 * @constructor
 */
function APNPushNotification(options) {
  BasePushNotification.apply(this, arguments);

  options = extend(true, {}, {
    device: '',
    notification: {
      aps: {
        alert: "\uD83D\uDCE7 \u2709 You have a new message",
        sound: 'ping.aiff',
        badge: 1
      },
      payload: {}
    }
  }, options);

  this.device = new apn.Device(options.device);
  this.notification = new apn.Notification(options.notification);
}

/**
 * Send push notification to device
 * @returns {APNPushNotification}
 */
APNPushNotification.prototype.send = function () {
  connection.pushNotification(this.notification, this.device);
  return this;
};

module.exports = APNPushNotification;<commit_msg>Rewrite apn push a little bit<commit_after>var apn = require('apn');
var util = require('util');
var BasePushNotification = require('./BasePushNotification');

util.inherits(APNPushNotification, BasePushNotification);

/**
 * Create new APN Push Notification
 * @param {Object} options
 * @returns {APNPushNotification}
 * @constructor
 */
function APNPushNotification(options) {
  BasePushNotification.apply(this, arguments);

  this.setProvider(new apn.Connection({
    cert: '',
    key: ''
  }));
}

/**
 * Create device instance
 * @param {Object} config
 * @returns {*}
 * @private
 */
APNPushNotification.prototype._createDevice = function (config) {
  return new apn.Device(config);
};

/**
 * Create notification instance
 * @param {Object} config
 * @returns {*}
 * @private
 */
APNPushNotification.prototype._createNotification = function (config) {
  return new apn.Notification(config);
};

/**
 * Send push notification to device
 * @returns {APNPushNotification}
 */
APNPushNotification.prototype.send = function () {
  this
    .getProvider()
    .pushNotification(this._createNotification(this.getConfig('notification')), this._createDevice(this.getConfig('device')));

  return this;
};

module.exports = APNPushNotification;
{'fraction_non_alphanumeric': 0.14214670534604226, 'fraction_numerical': 0.003315375051802735, 'mean_word_length': 4.549425287356322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7119056', 'n_tokens_mistral': 712, 'n_tokens_neox': 696, 'n_words': 153}