Quantcast
Viewing all articles
Browse latest Browse all 8068

ACS Push Notification Payload and to_ids help

I have been able to get ACS Push Notifications working on iOS with Titanium 3.2.2, but I want to take it one step further. I want to make it so the user can type in the payload and to_id in the Cloud.PushNotifications.notify so it sends a custom push notification message directly to a specific id in the channel. I tried testing the following code on my iPhone, but I get the error "Invalid to_ids format". I want to give the users more flexibility in the message they send, and also I want the messages to be "anonymous" which is why I do not want to use the friend parameter. I hoped the textfield value would replace the need for the to_ids parameter but that didn't work for me either. Any help is appreciated.

var Cloud = require('ti.cloud');
var deviceToken;
 
var User = Ti.UI.createTextField({
    borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    top: '50',
    left: '10',
    width: '300',
    height: '35',
    hintText: 'Enter User here'
});
 
win.add(User);
 
var reportProblem = Ti.UI.createTextField({
    borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
    top: '100',
    left: '10',
    width: '300',
    height: '35',
    hintText: 'Enter problem here'
});
 
win.add(reportProblem);
 
var send = Ti.UI.createButton({
    top: '150',
    width: '100',
    height: '25',
    title: 'Report',
    borderRadius:1,
    backgroundColor: '#68BDFF',
    font:{fontFamily:'Arial',fontWeight:'bold',fontSize:14}
});
 
win.add(send);
 
send.addEventListener('click', function(e)
{
    if(user != '' || reportProblem != '')
    {
    Cloud.PushNotifications.notify({
        channel: 'demo_alert',
        payload: reportProblem.value,
        badge: "+1",
        to_ids: user.value
    }, function (e) {
        if (e.success) {
            alert('Push notification sent');
        } else {
            alert('Error:\n' +
                ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>