[AC-1168] Titanium push set badge +1 doesnt seem to work
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-03-07T11:14:13.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | api, cloud, cloudpush, cloudservices, ios |
Reporter | Samuel East |
Assignee | Shuo Liang |
Created | 2015-03-05T14:10:16.000+0000 |
Updated | 2016-03-08T07:37:32.000+0000 |
Description
Hi All,
I have been trying to get push notifications to work for a while now everything is nearly there but i cannot seem to get the push badge to increment 1 on the application badge.
I am sending the payload like this.
~~~
{"alert":"This is a push message","badge": "+1","category": "sampleCategory","title":"Sending push","vibrate":true,"sound":"beep"}
~~~
The above does not work for me i can minus and it will work fine.
~~~
{"alert":"This is a push message","badge": "-1","category": "sampleCategory","title":"Sending push","vibrate":true,"sound":"beep"}
~~~
Full php code.
~~~
$username = "username_here";
$password = "password";
$channel = 'my_channel';
$title = "No Android";
$tmp_fname = 'cookie.txt';
$json = '{"alert":"This is a push message","badge": "+1","category": "sampleCategory","title":"' . $title . '","vibrate":true,"sound":"beep"}';
/*** PUSH NOTIFICATION ***********************************/
$post_array = array(
'login' => $username,
'password' => $password
);
/*** INIT CURL *******************************************/
$curlObj = curl_init();
$c_opt = array(
CURLOPT_URL => 'https://api.cloud.appcelerator.com/v1/users/login.json?key=' . $key,
CURLOPT_COOKIEJAR => $tmp_fname,
CURLOPT_COOKIEFILE => $tmp_fname,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => "login=" . $username . "&password=" . $password,
CURLOPT_FOLLOWLOCATION => 0,
CURLOPT_TIMEOUT => 60
);
/*** LOGIN **********************************************/
curl_setopt_array($curlObj, $c_opt);
$session = curl_exec($curlObj);
/*** SEND PUSH ******************************************/
$c_opt[CURLOPT_URL] = "https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=" . $key;
$c_opt[CURLOPT_POSTFIELDS] = "channel=" . $channel . "&payload=" . $json . "&to_ids=everyone";
curl_setopt_array($curlObj, $c_opt);
$session = curl_exec($curlObj);
echo $session;
curl_close($curlObj);
~~~
HI, Just test with my device, the badge property works well. You could test it with following curl command in terminal.
or
Regards, Shuo
Ok just running a test now
Hi Shuo, Apologies for wasting your time i found out why it wasn't working i needed to urlencode the payload now it works fine. $json = '{"alert":"' . $message . '","badge": "+1"}'; $c_opt[CURLOPT_POSTFIELDS] = "channel=" . $channel . "&payload=" . urlencode($json) . "&to_ids=everyone"; Please close Thanks