How to use @parse/node-apn - 4 common examples

To help you get started, we’ve selected a few @parse/node-apn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appfeel / node-pushnotifications / src / sendAPN.js View on Github external
sendAPN(regIds, data) {
    const message = new apn.Notification({
      retryLimit: data.retries || -1,
      expiry: extractExpiry(data),
      priority: data.priority === 'normal' ? 5 : 10,
      encoding: data.encoding,
      payload: data.custom || {},
      badge: data.badge,
      sound: data.sound,
      alert: data.alert || {
        title: data.title,
        body: data.body,
        'title-loc-key': data.titleLocKey,
        'title-loc-args': data.titleLocArgs,
        'loc-key': data.locKey,
        // bodyLocArgs is kept for backward compatibility
        'loc-args': data.locArgs || data.bodyLocArgs,
        'launch-image': data.launchImage,
github parse-community / parse-server-push-adapter / src / APNS.js View on Github external
static _createProvider(apnsArgs) {
    // if using certificate, then topic must be defined
    if (!APNS._validateAPNArgs(apnsArgs)) {
      throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'topic is mssing for %j', apnsArgs);
    }

    let provider = new apn.Provider(apnsArgs);

    // Sets the topic on this provider
    provider.topic = apnsArgs.topic;

    // Set the priority of the providers, prod cert has higher priority
    if (apnsArgs.production) {
      provider.priority = 0;
    } else {
      provider.priority = 1;
    }

    return provider;
  }
github parse-community / parse-server-push-adapter / src / APNS.js View on Github external
static _generateNotification(coreData, headers) {
    let notification = new apn.Notification();
    let payload = {};
    for (let key in coreData) {
      switch (key) {
        case 'aps':
          notification.aps = coreData.aps;
          break;
        case 'alert':
          notification.setAlert(coreData.alert);
          break;
        case 'title':
          notification.setTitle(coreData.title);
        break;
        case 'badge':
          notification.setBadge(coreData.badge);
          break;
        case 'sound':
github appfeel / node-pushnotifications / src / sendAPN.js View on Github external
constructor(settings) {
    try {
      this.connection = new apn.Provider(settings);
    } catch (e) {
      this.connectionError = e;
      this.connection = null;
    }
  }

@parse/node-apn

An interface to the Apple Push Notification service for Node.js

MIT
Latest version published 7 months ago

Package Health Score

73 / 100
Full package analysis