Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1375] Cloud PushNotifications expire_after_seconds issue

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionFixed
Resolution Date2014-03-14T08:46:30.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
LabelsCloud, PushNotifications, expire_after_seconds
ReporterStephan Jensen
AssigneeShuo Liang
Created2014-03-07T08:33:39.000+0000
Updated2016-03-08T07:37:47.000+0000

Description

Problem Description:

We are unable to use the expire_after_seconds option when using the REST API We are getting the following response { "meta": { "code": 400, "status": "fail", "message": "Invalid json format on options parameter: can't convert ActiveSupport::HashWithIndifferentAccess into String" } } \\

Testcase:

Uri https://api.cloud.appcelerator.com/v1/push_notification/notify_tokens.json?key= \\

Request headers

User-Agent: Fiddler Host: api.cloud.appcelerator.com Content-Length: 174 Cookie: Content-Type: application/json \\

Request body (POST)

{
	"channel": "test",
	"to_tokens": "everyone",
	"payload": {
		"alert": "Push Notification Test",
		"title": "this is the title"
	},
        "options": {"expire_after_seconds": 86400}
}

Comments

  1. Shuo Liang 2014-03-11

    Hi, I tested that API and check the source code. Are you sure you set options by the exactly same format {"expire_after_seconds": 86400}. because if you use single quotation marks like {'expire_after_seconds': 86400}, it will cause error then get the exception like you got. And there is something wrong with the documents. we have to use double quotation marks here.
  2. Stephan Jensen 2014-03-11

    Yes we are using double quotes We are still getting the same error as described above
  3. Shuo Liang 2014-03-12

    Would please tell me do you use the notify_token API in a app, or a curl commands? And can you pass parts of the code you wrote, I have to make sure the data format.
  4. Stephan Jensen 2014-03-12

    We have tried using the notify_tokens API both from .NET 4.0 and Fiddler Here's a screenshot of how we compose the fiddler request: !https://www.dropbox.com/s/fz41rw3d4r7z625/fiddler.jpg! https://www.dropbox.com/s/fz41rw3d4r7z625/fiddler.jpg We are also having trouble showing the letters æøå on android devices, they are being shown as ? symbols UTF-8 encoding is being used from our .NET application
  5. Shuo Liang 2014-03-14

    Hi, I am still testing notidy_tokens API's issue. Will notice you as soon as solve it. For the letter display problem, you may use ASCII code. Ref: http://www.ascii-code.com/
  6. Shuo Liang 2014-03-14

  7. Stephan Jensen 2014-03-14

    Thanks for the update We can't get the ASCII encoding to work with Å, Æ, Ø The iPhone accepts displays the ascii encoded characters correctly, but our android devices still shows ? symbols Your options fix seems to be working, so thanks for that :) Should I open a new issue about the encoding problem?
  8. Shuo Liang 2014-03-14

    Ye, Please create a new issue about encoding problem, thanks.
  9. Shuo Liang 2014-03-14

    Customer's options issue fixed.
  10. Stephan Jensen 2014-06-02

    The fix is no longer working. Everytime we try and apply the option expire_after_seconds, the API responds with a 500 Internal Server Error. You could guys Please fix the problem without having to apply a workaround.

    Test with previous workaround applied:

        {
        	"channel": "test",
        	"to_tokens": "everyone",
        	"payload":{
        		"alert": "Test message.",
        		"title": ""
        	},
        	"options": '{"expire_after_seconds": 3600}'
        }
        

    Response:

        {
          "meta": {
            "status":"fail",
            "code":500,
            "message":"Internal server error. The Appcelerator Cloud Services Team has just been notified of this problem."
          }
        }
        
  11. Shuo Liang 2014-06-03

    Hi, First of all, the "expire_after_seconds" quotes issue has been fixed, and will be deployed to production in next release. By the time, you won't need work around any more. Then, I have tested your problem in last comment. I can't reproduce your problem. The code works well for me. So would you please try "curl" command again, if still not working, can you send me part of your code which I can find the problem. Ref my example:
        Appc-MBP:Documents shuoliang$ curl -b cookies.txt -c cookies.txt -F "channel=Test 1" -F "to_tokens=everyone" -F "payload=Test Message" -F 'options={"expire_after_seconds":86400}' 'https://api.cloud.appcelerator.com/v1/push_notification/notify_tokens.json?key=H3PcVB7YSocRMbC8iGUoFtRxrGDFUfd1'
        {
          "meta": {
            "status": "ok",
            "code": 200,
            "method_name": "NotifyTokens"
          }
        }
        
    Regards, Shuo

JSON Source