Push Notification Services
In addition to support for AWS Simple Push Notification (SNS) service, DreamFactory 2.5 introduces two brand new Push Notification services - Apple Push Notification Service (APNS) and Google Cloud Messaging (GCM) service. Now, with this you can use DreamFactory's simple REST API to send push notifications to your Apps running on iOS and Android devices.
Contents
Apple Push Notification Service (APNS)
DreamFactory APNS allows DreamFactory to be used as your iOS push notification provider. This means your App can register user devices on DreamFactory using its API Key, then when it's time to send a push notification, you can just send the notification targeting an App and all devices registered under that App will receive the push notification.
Configuration
APNS is managed via the api/v2/system/service API endpoint under the system service and have the service_type
apns
. You can retrieve the full service type information using the API api/v2/system/service_type/apns.
Below is the format of a typical APNS configuration that exists in DreamFactory. You can use the API api/v2/system/service/<apns-id> to view this information.
{ //Choose a URL safe service name "name": "apn", //Choose a label for your service "label": "Apple Push Notification", //A short description of your service "description": "DreamFactory Apple Push Notification Service", //Boolean flag to activate/inactivate your service "is_active": true, //Service type "type": "apns", "config": { "certificate":"...", "passphrase": "**********", "environment": "dev", "service_event_map": [ { "event": "system.admin.session.post", "data": "Admin logged in." }, { "event": "system.admin.session.delete", "data": "Admin logged out." } ] } }
The following describes the configuration elements of this service.
Certificate
String. Required. Provide your iOS APNS certificate (.pem) file. If you have the pkcs12 (.p12) file from Apple keychain access, you can convert it to .pem file using the following command.
openssl pkcs12 -in my-certificate-file.p12 -out my-certificate-file.pem -nodes -clcerts
Replace my-certificate-file.p12 with the name of the certificate file you exported from Keychain Access.
Passphrase
String. Optional. If your certificate requires a Passphrase then enter it here.
Environment
String. Required. Select your iOS application environment - Development or Production.
Service Event Map
Array. Optional. Here you can tie this service to any number of system events. In the example above we have tied our service with two events - “system.admin.session.post” and “system.admin.session.delete”. These events are fired respectively when a system admin logs in and logs out of the DreamFactory and therefore, it automatically fires this APN service and sends push notification to targeted devices. You can enter the push notification message in the data field.
Usage
Once you have configured your DreamFactory APN service using the Admin application, head over to the API Docs tab and expand your service to see detail usage of your service.
Google Cloud Messaging (GCM) Service
Like the APNS, GCM service in DreamFactory also allows it to be used as your Android App's push notification provider. You can make your Android App register user devices on DreamFactory using the API Key and then send push notification to all devices targeting this App.
Configuration
GCM service is managed via the api/v2/system/service API endpoint under the system service and have the service_type
gcm
. You can retrieve the full service type information using the API api/v2/system/service_type/apns.
Below is the format of a typical GCM service configuration that exists in DreamFactory. You can use the API api/v2/system/service/<gcm-service-id> to view this information.
{ //Choose a URL safe service name "name": "gcm", //Choose a label for your service "label": "GCM Service", //A short description of your service "description": "DreamFactory GCM Service", //Boolean flag to activate/inactivate your service "is_active": true, //Service type "type": "apns", "config": { "api_key":"...", "environment": "dev", "service_event_map": [ { "event": "system.admin.session.post", "data": "Admin logged in." }, { "event": "system.admin.session.delete", "data": "Admin logged out." } ] } }
The following describes the configuration elements of this service.
Api Key
String. Required. Enter you GCM server API Key here.
Environment
String. Required. Select your Android application environment - Development or Production.
Service Event Map
Array. Optional. Here you can tie this service to any number of system events. In the example above we have tied our service with two events - “system.admin.session.post” and “system.admin.session.delete”. These events are fired respectively when a system admin logs in and logs out of the DreamFactory and therefore, it automatically fires this GCM service and sends push notification to targeted devices. You can enter the push notification message in the data field.
Usage
Once you have configured your DreamFactory GCM service using the Admin application, head over to the API Docs tab and expand your service to see detail usage of your service.
Amazon Simple Notification Service (SNS)
DreamFactory also has a native service for sending push notifications via Amazon Simple Notification Service (SNS). Once your configure your DreamFactory SNS service you will be able to use the features of SNS, such as managing Topics, Subscription, Application, Endpoints all via the DreamFactory REST API.
Configuration
{ //Choose a URL safe service name "name": "sns", //Choose a label for your service "label": "Amazon SNS", //A short description of your service "description": "DreamFactory Amazon SNS service", //Boolean flag to activate/inactivate your service "is_active": true, //Service type "type": "apns", "config": { "key": "...", "secret": "**********", "region": "us-east-1" } }
The following describes the configuration elements of this service.
Key
String. Required. Enter your AWS account root or IAM access key here.
Secret
String. Required. Enter your AWS account root or IAM secret key here.
Region
String. Required. Select the AWS region to be accessed by this service connection.
Usage
Once you have configured your DreamFactory SNS service using the Admin application, head over to the API Docs tab and expand your service to see detail usage of your service.