This application should give you a ready-made starting point for integrating notifications into your own apps with Twilio Notifications. Before we begin, we need to collect all the credentials we need to run the application:
Credential | Description |
---|---|
Twilio Account SID | Your main Twilio account identifier - find it on your dashboard. |
Twilio Credential SID | Adds notification ability to your app - generate one here. You'll need to provision your APN push credentials to generate this. See this guide on how to do that. |
Twilio Notification URL | The base URL for the Notifications API -- https://notifications.twilio.com |
Twilio Notification_Service SID | Use the create_service.js script to generate this. Just run 'node create_service.js' in your terminal. |
Create a configuration file for your application:
cp .env.example .env
Edit .env
with the four configuration parameters we gathered from above.
Next, we need to install our dependencies from npm:
npm install
Now we should be all set! Run the application using the npm
command.
npm start
Your application should now be running at http://localhost:3000.
When your app receives a 'registration' in the form of a POST request to the /register endpoint from a mobile client, it will create a binding. A binding is the address Twilio gives your app installation. It lets our service know where to send notifications.
To send a notification to the client run the notify script
node notify IDENTITY_HERE
The mobile client will receive a notification with the hardcoded 'Hello Bob' message.
That's it! Check out our REST API docs for more information on Twilio Notifications.
MIT