Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@parse/push-adapter

parse-community276.8kMIT6.11.0

Base parse-server-push-adapter

parse-server, push, adapter

readme

Parse Server Push Adapter

Build Status Snyk Badge Coverage auto-release

Node Version

npm latest version


The official Push Notification adapter for Parse Server. See Parse Server Push Configuration for more details.


Installation

npm install --save @parse/push-adapter@<VERSION>

Replace <VERSION> with the version you want to install.

Configure Parse Server

import { ParsePushAdapter } from '@parse/push-adapter';

// For CommonJS replace the import statemtent above with the following line:
// const ParsePushAdapter = require('@parse/push-adapter').default;

const parseServerOptions = {
  push: {
    adapter: new ParsePushAdapter({
      ios: {
        // Apple push options
      },
      android: {
        // Android push options
      },
      web: {
        // Web push options
      },
      expo: {
        // Expo push options
      }
    })
  }
  // Other Parse Server options
};

Apple Push Options

Parse Server Push Adapter currently supports these types of Apple ecosystems:

  • ios: iPhone, iPad, and iPod touch apps
  • osx: macOS, and macCatalyst apps
  • tvos: tvOS apps
  • watchos: watchOS apps

Push notifications can be delivered to Apple devices either via Apple Push Notification Service (APNS) or Firebase Cloud Messaging (FMC). Note that each category of Apple devices requires their own configuration section:

  • APNS requires a private key that can be downloaded from the Apple Developer Center at https://developer.apple.com/account under Certificates > Identifiers & Profiles. The adapter options also require the app ID and team ID, which can be found there.
  • FCM requires a private key that can be downloaded from the Firebase Console at https://console.firebase.google.com in your project under Settings > Cloud Messaging.

Example options:

Both services (APNS, FCM) can be used in combination for different Apple ecosystems.

ios: {
  // Deliver push notifications to iOS devices via APNS
  token: {
    key: __dirname + '/apns.p8',
    keyId: '<APNS_KEY_ID>',
    teamId: '<APNS_TEAM_ID>'
  },
  topic: '<BUNDLE_IDENTIFIER>',
  production: true
},
osx: {
  // Deliver push notifications to macOS devices via FCM
  firebaseServiceAccount: __dirname + '/firebase.json'
}

Android Push Options

Delivering push notifications to Android devices can be done via Firebase Cloud Messaging (FCM):

Example options:

android: {
  firebaseServiceAccount: __dirname + '/firebase.json'
}

Firebase Cloud Messaging (FCM)

This section contains some considerations when using FCM, regardless of the destination ecosystems the push notification is sent to.

Google Cloud Service Account Key

The Firebase console allows to easily create and download a Google Cloud service account key JSON file with the required permissions. Instead of setting firebaseServiceAccount to the path of the JSON file, you can provide an object representing a Google Cloud service account key:

android: {
  firebaseServiceAccount: {
    projectId: '<PROJECT_ID>',
    clientEmail: 'example@<PROJECT_ID>.iam.gserviceaccount.com',
    privateKey: '-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n'
  }
}

This can be helpful if you are already managing credentials to Google Cloud APIs in other parts of your code and you want to reuse these credentials, or if you want to manage credentials on a more granular level directly in Google Cloud. Make sure that the service account has the permission cloudmessaging.messages.create which is for example part of role Firebase Cloud Messaging API Admin.

Migration to FCM HTTP v1 API (June 2024)

⚠️ Sending push notifications to Android devices via the FCM legacy API was deprecated on June 20 2023 and was announced to be decommissioned in June 2024. See Google docs. To send push notifications to the newer FCM HTTP v1 API you need to update your existing push configuration for Android by replacing the key apiKey with firebaseServiceAccount.

Example options (deprecated):

android: {
  // Deliver push notifications via FCM legacy API (deprecated)
  apiKey: '<API_KEY>'
}

HTTP/1.1 Legacy Option

With the introduction of the FCM HTTP v1 API, support for HTTP/2 was added which provides faster throughput for push notifications. To use the older version HTTP/1.1 set fcmEnableLegacyHttpTransport: true in your push options.

Example options:

android: {
  firebaseServiceAccount: __dirname + '/firebase.json',
  fcmEnableLegacyHttpTransport: true
}

Firebase Client Error

Occasionally, errors within the Firebase Cloud Messaging (FCM) client may not be managed internally and are instead passed to the Parse Server Push Adapter. These errors can occur, for instance, due to unhandled FCM server connection issues.

  • resolveUnhandledClientError: true: Logs the error and gracefully resolves it, ensuring that push sending does not result in a failure.
  • resolveUnhandledClientError: false: Causes push sending to fail, returning a Parse.Error.OTHER_CAUSE with error details that can be parsed to handle it accordingly. This is the default.

In both cases, detailed error logs are recorded in the Parse Server logs for debugging purposes.

Expo Push Options

Example options:

expo: {
  accessToken: '<EXPO_ACCESS_TOKEN>'
}

For more information see the Expo docs.

Bundled with Parse Server

Parse Server already comes bundled with a specific version of the push adapter. This installation is only necessary when customizing the push adapter version that should be used by Parse Server. When using a customized version of the push adapter, ensure that it's compatible with the version of Parse Server you are using.

When using the bundled version, it is not necessary to initialize the push adapter in code and the push options are configured directly in the push key, without the nested adapter key:

const parseServerOptions = {
  push: {
    ios: {
      // Apple push options
    }
    // Other push options
  }
  // Other Parse Server options
};

Logging

You can enable verbose logging to produce a more detailed output for all push sending attempts with the following environment variables:

VERBOSE=1

or

VERBOSE_PARSE_SERVER_PUSH_ADAPTER=1

changelog

6.11.0 (2025-03-16)

Features

  • Bump @parse/node-apn from 6.4.3 to 6.5.0 (#382) (3995754)

6.10.0 (2025-01-18)

Features

  • Add support for watchOS push notifications (#360) (97f14ca)

6.9.1 (2025-01-01)

Bug Fixes

  • APN notification topic not composed based on push type (#347) (9905c34)

6.9.0 (2024-12-30)

Features

6.8.0 (2024-12-14)

Features

  • Add FCM option resolveUnhandledClientError to resolve or reject push promise on FCM server response GOAWAY (#341) (6d72f8a)

6.7.1 (2024-11-19)

Bug Fixes

  • Security upgrade @parse/node-apn from 6.2.0 to 6.2.1 (#329) (5cd5170)

6.7.0 (2024-09-27)

Features

  • Upgrade @parse/node-apn from 6.1.0 to 6.2.0 (#310) (c71e167)

6.6.0 (2024-09-24)

Features

  • Bump @parse/node-apn from 6.0.1 to 6.1.0 (#304) (b5d4c59)

6.5.0 (2024-08-02)

Features

  • Add Firebase Cloud Messaging (FCM) HTTP/2 support and option fcmEnableLegacyHttpTransport to use legacy HTTP/1.1 (#274) (70e6b6f)

6.4.1 (2024-07-08)

Bug Fixes

  • Verbose mode is enabled if environment variables VERBOSE or VERBOSE_PARSE_SERVER_PUSH_ADAPTER are set to any value (#264) (0f31300)

6.4.0 (2024-07-07)

Features

6.3.0 (2024-07-07)

Features

6.2.0 (2024-05-15)

Features

  • Add support for Expo push notifications (#243) (8987b85)

6.1.1 (2024-05-15)

Bug Fixes

  • FCM push notification payload incompatible with Parse Android SDK (#238) (4274b7f)

6.1.0 (2024-05-04)

Features

  • Add support for web push notifications (#239) (93b6a48)

6.0.0 (2024-03-30)

Features

BREAKING CHANGES

  • Removes support for Node 14 and 16 (bb0ff82)

5.2.0 (2024-03-30)

Features

  • Add backwards compatibility with APNS payloads when using Firebase Cloud Messaging API (HTTP v1) (#234) (b9a41d1)

5.1.1 (2024-03-02)

Bug Fixes

  • Security upgrade firebase-admin from 11.10.1 to 12.0.0 (#231) (2c3d61d)

5.1.0 (2024-03-02)

Features

  • Send Android push notifications to Firebase Cloud Messaging API (HTTP v1) by setting the push adapter option firebaseServiceAccount (#222) (be40b1d)

5.0.2 (2023-10-21)

Bug Fixes

  • Security upgrade semver-regex from 3.1.3 to 3.1.4 (#210) (089149b)

5.0.1 (2023-10-21)

Bug Fixes

  • Security upgrade qs from 6.5.2 to 6.5.3 (#215) (7fe2446)

5.0.0 (2023-10-21)

Features

  • Upgrade to node-apn 6.0.1, parse 4.2.0 (#227) (615e730)

BREAKING CHANGES

  • This release removes support for Node 12; the minimum required version is Node 14. (615e730)

4.2.5 (2023-10-21)

Bug Fixes

  • Security upgrade json-schema and jsprim (#226) (83ca68f)

4.2.4 (2023-10-21)

Bug Fixes

  • Security upgrade @babel/traverse from 7.17.3 to 7.23.2 (#225) (afdb28e)

4.2.3 (2023-10-21)

Bug Fixes

  • Security upgrade decode-uri-component from 0.2.0 to 0.2.2 (#214) (16863c0)

4.2.2 (2023-10-21)

Bug Fixes

  • Security upgrade http-cache-semantics from 4.1.0 to 4.1.1 (#216) (ba48dd6)

4.2.1 (2023-10-02)

Bug Fixes

  • Upgrade @parse/node-apn from 5.2.1 to 5.2.3 (#221) (7aaab38)

4.2.0 (2023-08-06)

Features

  • Upgrade @parse/node-apn from 5.1.3 to 5.2.1 (#220) (3b932d1)

4.1.3 (2023-05-20)

Bug Fixes

  • Validate push notification payload; fixes a security vulnerability in which the adapter can crash Parse Server due to an invalid push notification payload (#217) (598cb84)

4.1.2 (2022-03-27)

Bug Fixes

  • security bump node-apn 5.1.0 to 5.1.3 (#207) (7257c9a)

4.1.1 (2022-03-27)

Bug Fixes

  • security bump node-fetch from 2.6.6 to 2.6.7 (#206) (3b41a4e)

4.1.0 (2021-11-21)

Features

  • add support for APNS interruption-level and target-content-id (#197) (e0541ec)

4.0.0

Full Changelog

BREAKING CHANGE

  • node-apn 5 requires node >= 12 (#198)

Bug Fixes

  • bump node-apn to 5.0 (#198)

3.4.1

Full Changelog

  • Security fixes (Manuel Trezza) #193

3.4.0 (2020-10-19)

Full Changelog

3.3.0 (2020-09-24)

Full Changelog

3.2.0 (2019-10-26)

Full Changelog

  • Support headers (expiration_time, collapse_id, push_type, priority) in data field (#148) (thanks to @dplewis)
  • parse@2.8.0

3.1.0 (2019-10-03)

Full Changelog

  • Update @parse/node-apn.
  • Update parse.

3.0.10 (2019-08-26)

Full Changelog

Use @parse/node-apn served from npm instead of using our fork served from github.

3.0.9 (2019-07-30)

Full Changelog

Fix: Update node-apn version and improve publish script (#141) (thanks to @davimacedo)

3.0.8 (2019-07-26)

Full Changelog

Last release had its lib/ folder published but it's failing in parse-server tests. Trying to fix.

3.0.7 (2019-07-26)

Full Changelog

New attempt to fix last release since it was published empty to npm.

3.0.6 (2019-07-26)

Full Changelog

Fix last release since it was published empty to npm.

3.0.5 (2019-07-26)

Full Changelog

Trying to make Travis publish to npm.

3.0.4 (2019-07-26)

Full Changelog

What's new

3.0.3 (2019-07-12)

Full Changelog

Continuing attempt to get travis to deploy to npm on release. Third time's a charm?

3.0.2 (2019-07-12)

Full Changelog

Update Travis to deploy the correct repo to npm

3.0.1 (2019-07-11)

Full Changelog

Update Packages to address security alerts

2.0.3 (2018-04-13)

Full Changelog

What's new

  • Use updated node-gcm version from @parse org. with safe request version

2.0.2 (2017-10-22)

Full Changelog

What's new

  • Adds ability to pass apn key for iOS pushes

2.0.1 (2017-10-21)

Full Changelog

What's new

  • Fixes issue setting the push notificaiton title

2.0.0 (2017-03-14)

Full Changelog

What's new

  • Adds support for APNS notification title
  • Adds support for APN collapse-id

2.0.0-alpha.1 (2017-03-14)

Full Changelog

What's new

  • Adds support for APNS with HTTP/2.0
  • Improvements in testing, tooling

1.3.0 (2017-03-14)

Full Changelog

Closed issues:

  • Modernize dependencies and test tools #60
  • Fixed link for Parse-server push configuration #57

Merged pull requests:

1.2.0 (2017-01-16)

Full Changelog

Closed issues:

  • Classify installation with pushType and failback with deviceType #31
  • Send deviceType key to push handler #39
  • Added notification field for fcm #41
  • fixes 64k limit on GCM push. #49

1.1.0 (2016-08-25)

Full Changelog

Closed issues:

  • New release for mutableContent #28
  • APNS TypeError: Cannot read property 'key' of undefined #24
  • Can not find sender for push type android/ios #16
  • APNS adapter failure -- cannot find valid connection #15
  • pushing to thousands of installations #9
  • Push is not delivered to iOS device #8
  • Push not sent to iOS Device #4

Merged pull requests:

v1.0.4 (2016-03-30)

Full Changelog

Closed issues:

  • Push notifications not sent #2

Merged pull requests:

v1.0.3 (2016-03-26)

Full Changelog

Merged pull requests:

v1.0.2 (2016-03-26)

Full Changelog

Merged pull requests:

  • reports all sending error for mis-configurations #3 (flovilmart)

v1.0.1 (2016-03-25)

Full Changelog

Merged pull requests:

v1.0.0 (2016-03-25)

* This Change Log was automatically generated by github_changelog_generator