We start with some basic styling to display our elements in a readable fashion. When the page loads, we'll be showing Tap to Send Push in large letters in the center of the screen.
The config object must be updated.
ppgUrl: Update the cpid to match your own unique URL.
appId: Update to match the App ID provided with your own Push credentials. The digits before the hyphen (-) should match yoru cpid.
pwd: Update to match the Pwd provided with your own Push credentials; this is found under the Server section of the email.
recipient: Currently we are dynamically sending to ourselves. You can replace this with push_all to send to all recipients that are registered with your push service.
This sample application is only set up to push to one address (1 recipient or push_all.) If you want to push to multiple recipients, you will need to modify the template to include a unique <address> element for each recipient.
data: The string that you want to send.
We use a template for the push defined in postData. Inside of this template are a number of tags that we replace with the actual push content. For example:
$(boundary), $(pushid), etc. These are simply strings that we look for and replace. The $ has no special meaning.
We then perform a standard XMLHttpRequest (Ajax) POST with our combined data.
Finally, in the load event, we are adding a touchstart listener to the main <div> element to allow us to initiate a push.