Search code examples
xtify

How can I cancel a notification with xtify?


I'm using xtify to send GCM notification. I receive it with OnMessage event but I want to keep this notification, modify it and send the new one. But I receive the two notifications. How can I cancel the first one?

If I decide not show it, it works. But if I show my notification, then appears the two.

Thank you.


Solution

  • If you want receive notification data with OnMessage and then show your notification (without showing SDK default notification), all you have to do is set the notification action to NONE (in the APIs or website), example:

    URL: http://api.xtify.com/2.0/push

    Content-Type: application/json

    HTTP entity body:

    {
        "apiKey": "xxxxxx-xxxxx-xxxx-xxxxx",
        "appKey": "xxxxxx-xxxxx-yyyy-xxxxx",
        "xids": ["xxxxxxxxxxxxxxxxxx"],
        "sendAll": true,
        "content": {
            "subject": "Greetings Earthlings",
            "message": "Take me to your leader",
            "action": {
                "type": "NONE" // All visual and audible alerts will be suppressed
            }
        }
    }
    

    The behavior of all actions are documented here:

    NONE: All visual and audible alerts will be suppressed. Use this feature to send data to an application without disrupting the user.