{ "id": "145438", "key": "AC-1168", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2015-03-07T11:14:13.000+0000", "created": "2015-03-05T14:10:16.000+0000", "labels": [ "api", "cloud", "cloudpush", "cloudservices", "ios" ], "versions": [], "issuelinks": [], "assignee": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "updated": "2016-03-08T07:37:32.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Hi All,\r\nI 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.\r\nI am sending the payload like this.\r\n~~~\r\n{\"alert\":\"This is a push message\",\"badge\": \"+1\",\"category\": \"sampleCategory\",\"title\":\"Sending push\",\"vibrate\":true,\"sound\":\"beep\"}\r\n~~~\r\nThe above does not work for me i can minus and it will work fine.\r\n~~~\r\n{\"alert\":\"This is a push message\",\"badge\": \"-1\",\"category\": \"sampleCategory\",\"title\":\"Sending push\",\"vibrate\":true,\"sound\":\"beep\"}\r\n~~~\r\nFull php code.\r\n~~~\r\n$username = \"username_here\";\r\n $password = \"password\";\r\n $channel = 'my_channel';\r\n $title = \"No Android\";\r\n $tmp_fname = 'cookie.txt';\r\n $json = '{\"alert\":\"This is a push message\",\"badge\": \"+1\",\"category\": \"sampleCategory\",\"title\":\"' . $title . '\",\"vibrate\":true,\"sound\":\"beep\"}';\r\n \r\n /*** PUSH NOTIFICATION ***********************************/\r\n \r\n $post_array = array(\r\n 'login' => $username,\r\n 'password' => $password\r\n );\r\n \r\n /*** INIT CURL *******************************************/\r\n $curlObj = curl_init();\r\n $c_opt = array(\r\n CURLOPT_URL => 'https://api.cloud.appcelerator.com/v1/users/login.json?key=' . $key,\r\n CURLOPT_COOKIEJAR => $tmp_fname,\r\n CURLOPT_COOKIEFILE => $tmp_fname,\r\n CURLOPT_RETURNTRANSFER => true,\r\n CURLOPT_POST => 1,\r\n CURLOPT_POSTFIELDS => \"login=\" . $username . \"&password=\" . $password,\r\n CURLOPT_FOLLOWLOCATION => 0,\r\n CURLOPT_TIMEOUT => 60\r\n );\r\n \r\n /*** LOGIN **********************************************/\r\n curl_setopt_array($curlObj, $c_opt);\r\n $session = curl_exec($curlObj);\r\n \r\n /*** SEND PUSH ******************************************/\r\n $c_opt[CURLOPT_URL] = \"https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=\" . $key;\r\n $c_opt[CURLOPT_POSTFIELDS] = \"channel=\" . $channel . \"&payload=\" . $json . \"&to_ids=everyone\";\r\n \r\n curl_setopt_array($curlObj, $c_opt);\r\n $session = curl_exec($curlObj);\r\n \r\n echo $session;\r\n \r\n curl_close($curlObj);\r\n~~~", "attachment": [], "flagged": false, "summary": "Titanium push set badge +1 doesnt seem to work", "creator": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "IOS", "comment": { "comments": [ { "id": "345258", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "HI,\r\n\r\nJust test with my device, the badge property works well. You could test it with following curl command in terminal.\r\n\r\n{code}\r\ncurl -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=&pretty_json=true\"\r\n{code}\r\n\r\nor \r\n\r\n{code}\r\ncurl -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=&pretty_json=true\"\r\n{code}\r\n\r\nRegards,\r\nShuo\r\n", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2015-03-06T10:21:53.000+0000", "updated": "2015-03-06T10:21:53.000+0000" }, { "id": "345260", "author": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Ok just running a test now", "updateAuthor": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-03-06T10:34:41.000+0000", "updated": "2015-03-06T10:34:41.000+0000" }, { "id": "345263", "author": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Shuo,\r\n\r\nApologies for wasting your time i found out why it wasn't working i needed to urlencode the payload now it works fine.\r\n\r\n$json = '{\"alert\":\"' . $message . '\",\"badge\": \"+1\"}';\r\n$c_opt[CURLOPT_POSTFIELDS] = \"channel=\" . $channel . \"&payload=\" . urlencode($json) . \"&to_ids=everyone\";\r\n\r\nPlease close\r\n\r\nThanks", "updateAuthor": { "name": "samueleast", "key": "samueleast", "displayName": "Samuel East", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-03-06T11:07:53.000+0000", "updated": "2015-03-06T11:07:53.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }