Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork108
A push notification adapter for Parse Server
License
parse-community/parse-server-push-adapter
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The official Push Notification adapter for Parse Server. SeeParse Server Push Configuration for more details.
npm install --save @parse/push-adapter@<VERSION>
Replace<VERSION> with the version you want to install.
import{ParsePushAdapter}from'@parse/push-adapter';// For CommonJS replace the import statemtent above with the following line:// const ParsePushAdapter = require('@parse/push-adapter').default;constparseServerOptions={push:{adapter:newParsePushAdapter({ios:{// Apple push options},android:{// Android push options},web:{// Web push options},expo:{// Expo push options}})}// Other Parse Server options};
Parse Server Push Adapter currently supports these types of Apple ecosystems:
ios: iPhone, iPad, and iPod touch appsosx: macOS, and macCatalyst appstvos: tvOS appswatchos: 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 athttps://developer.apple.com/account underCertificates > 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 athttps://console.firebase.google.com in your project underSettings > 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 APNStoken:{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 FCMfirebaseServiceAccount:__dirname+'/firebase.json'}
Delivering push notifications to Android devices can be done via Firebase Cloud Messaging (FCM):
- FCM requires a private key that can be downloaded from the Firebase Console athttps://console.firebase.google.com in your project underSettings > Cloud Messaging.
Example options:
android:{firebaseServiceAccount:__dirname+'/firebase.json'}
This section contains some considerations when using FCM, regardless of the destination ecosystems the push notification is sent to.
The Firebase console allows to easily create and download a Google Cloud service account key JSON file with the required permissions. Instead of settingfirebaseServiceAccount 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 permissioncloudmessaging.messages.create which is for example part of roleFirebase Cloud Messaging API Admin.
apiKey withfirebaseServiceAccount.
Example options (deprecated):
android:{// Deliver push notifications via FCM legacy API (deprecated)apiKey:'<API_KEY>'}
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 setfcmEnableLegacyHttpTransport: true in your push options.
Example options:
android:{firebaseServiceAccount:__dirname+'/firebase.json',fcmEnableLegacyHttpTransport:true}
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 aParse.Error.OTHER_CAUSEwith 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.
Example options:
expo:{accessToken:'<EXPO_ACCESS_TOKEN>'}
For more information see theExpo docs.
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 thepush key, without the nestedadapter key:
constparseServerOptions={push:{ios:{// Apple push options}// Other push options}// Other Parse Server options};
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
About
A push notification adapter for Parse Server
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.