Skip to content

Instantly share code, notes, and snippets.

@adambutler
Last active August 29, 2015 14:04
Show Gist options
  • Save adambutler/c059c96c29d827e9d68b to your computer and use it in GitHub Desktop.
Save adambutler/c059c96c29d827e9d68b to your computer and use it in GitHub Desktop.
Cordova Push-notifications with Parse

Parse

  1. Create an application
  2. Goto Data Browser
  3. Create a new class, select installation
  4. Add a new column call it Id

Apple Developer

  1. Create a certificate and provisioning profile for push
  2. Upaload the certificate to the parse application

Cordvoa

  1. Install the PushPlugin
  2. Follow guilde for "Automatic Installation"
  3. Init PushPlugin with

var pushNotification;

document.addEventListener("deviceready", function(){
    pushNotification = window.plugins.pushNotification;
    ...
});
  1. Send your device push token by following the register instructions. When you AJAX the token to Parse also send <MyApp>Id

Trigger a notification

  1. Follow the parse guide for sending notifications

curl -X POST
-H "X-Parse-Application-Id: ${APPLICATION_ID}"
-H "X-Parse-REST-API-Key: ${REST_API_KEY}"
-H "Content-Type: application/json"
-d '{ "where": { "injuryReports": true }, "data": { "alert": "Willie Hayes injured by own pop fly." } }'
https://api.parse.com/1/push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment