i ma a coldfusion programmer i have the pushwuoosh alert messages working in the control panel and reaching my phone i now need to be able to run the necessari remote api code so that when certain events occur the code will fire and send off the necessary dynamically created messages to the specific users device

any assistance with sample code would be great

asked 12 May '16, 06:12
trackingcentral's gravatar image

trackingcentral
2115

edited 27 May '16, 07:01

Here's the CFML for using the PW API:

< cfhttp url="http://cp.pushwoosh.com/json/1.3/createMessage"
port="80"
method="post"
timeout="20"
>
< cfhttpparam type="header" name="Content-type" value="application/json">
< cfhttpparam type="body" value="#jsonReq#">
< /cfhttp>

A couple of things to note. For older versions of CF use port 80, otherwise try using port 443 and use https in the URL.

The var jsonReq should contain your JSON call to the API.

e.g.

< cfset jsonReq='{
    "request": {
        "application": "your PW application ID goes here",
        "auth": "your PW API auth key goes here",
        "notifications": [{
        "send_date": "now",
        "ignore_user_timezone": true,
        "content": "Hello world"
        }]
    }
}'>

To check the response from the PW server:

 < cfdump var="#cfhttp#" label="cfhttp">
permanent link
answered 16 May '16, 20:32
Gary_oo's gravatar image

Gary_oo
1015

I'm at the same stage as you. I know you need to use cfhttp to post the json request to the api but this isn't working for me yet. The problem might be using https and the underlying Java engine needs the Pushwoosh SSL cert copied into its keystore.

What version of CF do you use? I'm on 8.01. Newer versions like 10 onwards might automatically handle the https issue.

The alternative method is to use cfexecute and run CURL. But I'd prefer to focus on cfhttp first.

permanent link
answered 16 May '16, 03:15
Gary_oo's gravatar image

Gary_oo
1015

Sorry, I should have posted this as a comment because this is not a proper answer, it's merely some guidance.

(16 May '16, 03:17) Gary_oo Gary_oo's gravatar image

Well Done Garry it works a treat !!!!!

permanent link
answered 16 May '16, 21:54
trackingcentral's gravatar image

trackingcentral
2115

Hi

At moment i have pushwosh working well with my cf app each time i run a process in my coldfusion developed system to send a push alert it sends perfectly even when i run a scheduled task etc sending to my appid hard coded into the cfcode

Now i need to be able to dynamically send to specific users. I know i need to identify the app registration id each time an app is opened dynamically and use that value when creating the ios channel

do you have any advise on how i take the app to the next level now that i have it working as expected to my hard coded app id

permanent link
answered 27 May '16, 00:50
trackingcentral's gravatar image

trackingcentral
2115

The answer is documented: http://docs.pushwoosh.com/docs/createmessage

You need to use the "devices" parameter and include an array of device IDs that you want to receive your PN.

(27 May '16, 01:04) Gary_oo Gary_oo's gravatar image

Hi Gary

I assume thats how i populate the device id's that need to be sent the outbound message.

I would populate that value form the cfm page was the user / or a query will determine which user needs to have the message sent to their respective apps "i think i am across that"

my question is how do i capture the ids at the time the app is downloaded and installed (where i assume the device is determined ???) so that i can then store that value in my sqldbase against the specifc app users profile ???

am i on the right page ???

I am also told the device ID can potentially change after a reboot or device reset of the device is that correct from your experience and if so the device id needs to be re confirmed and sent to my system and updated each time the app opens in case there has been a device id change ????

separate note, i am really amazed at the lack of support replies in the community for all support posts many posts have plenty of people who view the post but majority of posts do not seem to have any replies, does not say a great deal about "community suppot" by the pushwoosh community

looking forward to the reply

permanent link
answered 27 May '16, 01:54
trackingcentral's gravatar image

trackingcentral
2115

The device ID used by Pushwoosh (and probably others) appears to be exactly the same as the one you'll get from the Cordova method device.uuid. After your app has initiated you could send the device.uuid to your server's database to build your list of client device IDs.

permanent link
answered 27 May '16, 02:02
Gary_oo's gravatar image

Gary_oo
1015

Hi Gary i am using following code found on corodva docs to try and get the deviceUUID

however the output on my iphne when i run this script is "Loading device properties"

all i am trying to do is find the code so i can output UUID and then use it in my app each time the app loads

<html> <head> <title>Device Properties Example</title>
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

        // Wait for device API libraries to load
        //
        document.addEventListener("deviceready", onDeviceReady, false);

        // device APIs are available
        //
        function onDeviceReady() {
            var element = document.getElementById('deviceProperties');
            element.innerHTML = 'Device Model: '    + device.model    + '<br />' +
            'Device Cordova: '  + device.cordova  + '<br />' +
            'Device Platform: ' + device.platform + '<br />' +
            'Device UUID: '     + device.uuid     + '<br />' +
            'Device Version: '  + device.version  + '<br />';
        }

        </script>
</head>
<body>
    <p id="deviceProperties">Loading device properties...</p>
</body>

</html>

permanent link
answered 27 May '16, 07:01
trackingcentral's gravatar image

trackingcentral
2115

Are you using PhoneGap Build to create an ipa file and then installing the app onto your iPhone? If so then delete the line of code that calls cordova.js because PGB will automatically insert it.

Or are you copying an HTML file onto your iPhone and opening it in Safari? This won't work, you need to upload your files (complete with config.xml) to PGB and get it to build an ipa file.

permanent link
answered 27 May '16, 11:19
Gary_oo's gravatar image

Gary_oo
1015

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×444
×83
×10

question asked: 12 May '16, 06:12

question was seen: 2,870 times

last updated: 27 May '16, 11:19