This project leverages the Amazon Simple Notification Service (SNS), which attempts to abstract away the complexities of different push notification systems. Currently, there is only support for iOS (Apple Push Notification Service) and Android (Google Cloud Messaging) devices.
To add other push types, you simply need to know what kind of payload format to be sent. This adapter leverages code from the parse-server-push-adapter repo. See the Amazon documentation if you wish to add other types.
The steps basically entail:
- Adding Platform endpoints to AWS console
- Apple requires you loading the prod/development certificates.
- Setup an IAM role for platform endpoints.
- Generate AWS access key and secret with this authorized IAM role.
- Enable CloudSearch logs for debugging.
- Configure Parse server
- Sign into the Amazon Web Services (AWS) Console.
- Select the
SNS
Service. - Select
Create Platform Application
.- For GCM setup, you must provide an API key. See the instructions about how to generate this key.
- For APNS setup, you must generate an SSL certificate that can connect to Apple's servers. See step #1 of this tutorail. You will need to choose between
Apple Production
andApple Development
depending on the cert generated.
- Record the Amazon Resource Number (ARN) associated with this new endpoint.
- Go to the Amazon IAM console.
- Create a user that will be granted access to SNS.
- Select the
Policies
tab and click on theCreate Policy
button. - Select
Create Your Own Policy
and fill out aPolicy Name
. - Copy this Policy document that will grant blanket access to SNS services. You can add more restrictions later.
{ "Version": "2012-10-17", "Statement": [ { "Action": [ "sns:*" ], "Effect": "Allow", "Resource": "*" } ] }
- Make sure to
Validate the Policy
and clickCreate Policy
. - Go back to the
Users
tab and select the user you created earlier. - In Permissions, select
Attach Policy
and find the policy we just created to attach it. - Click on
Security Credentials
and click onCreate Access Key
. - Record the credentials, which will be used to configure the Parse server.
Here is a sample config setup:
var pushConfig = { pushTypes : { android: {ARN : YOUR-ANDROID_ARN-HERE},
ios: {ARN: YOUR-IOS_ARN-HERE}, production: false, bundleId: "beta.parseplatform.yourappname"}
},
accessKey: process.env.SNS_ACCESS_KEY,
secretKey: process.env.SNS_SECRET_ACCESS_KEY,
region: "us-west-2"
};
var SNSPushAdapter = require('parse-server-sns-adapter/SNSPushAdapter').default;
var snsPushAdapter = new SNSPushAdapter(pushConfig);
pushConfig['adapter'] = snsPushAdapter;
You then need to instantiate the ParseServer info with the following:
var api = new ParseServer({
push: pushConfig
});