Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1168] Titanium push set badge +1 doesnt seem to work

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2015-03-07T11:14:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsapi, cloud, cloudpush, cloudservices, ios
ReporterSamuel East
AssigneeShuo Liang
Created2015-03-05T14:10:16.000+0000
Updated2016-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); ~~~

Comments

  1. Shuo Liang 2015-03-06

    HI, Just test with my device, the badge property works well. You could test it with following curl command in terminal.
       curl -b cookies.txt -c cookies.txt -F "channel=test" -F "to_ids=54f670e4ac4547febd2aa49c" -F 'payload={"alert""Sample alert", "badge":"+1"}' "https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=<;key>&pretty_json=true"
       
    or
       curl -X POST -F "channel=test" -F "to_tokens=d2b5f621d9eebb87d6ec83497e226d458567887fe207246f43116c80d763e657" -F 'payload={"alert":"Sample alert", "badge":"+2"}' "https://api.cloud.appcelerator.com/v1/push_notification/notify_tokens.json?key=<;key>&pretty_json=true"
       
    Regards, Shuo
  2. Samuel East 2015-03-06

    Ok just running a test now
  3. Samuel East 2015-03-06

    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

JSON Source