Ionic-push: what does expiry stand for?


#1

(In the following I’m referring to the docs here on “Sending Push”)

Hey there,

I’m currently trying to send push notifications via REST. I can send notifications via the cli, but it doesn’t work via the REST-Service. The REST-Service responds with result: queued but my device won’t receive any notifications. So I guess the object I’m sending might be faulty. For example I’m struggling with getting the idea of the expiry value. Is it a timestamp? Is it just an amount of milliseconds until the message has to disappear?

Sadly the docs aren’t very clear on what each key/value pair means in detail.

So my questions essentially are:

  • What does expiry stand for?
  • What does priority stand for?
  • Is there any better source than the docs?
  • Do you have any idea where my fault is?

Thanks in advance!

This is the example object (which I’ve changed for my purposes in my REST-request of-course, namely the device tokens, and the authorization header and X-Ionic-Application-Id header, so really nothing is missing):

{
  "tokens":[
    "b284a6f7545368d2d3f753263e3e2f2b7795be5263ed7c95017f628730edeaad",
    "d609f7cba82fdd0a568d5ada649cddc5ebb65f08e7fc72599d8d47390bfc0f20"
  ],
  "notification":{
    "alert":"Hello World!",
    "ios":{
      "badge":1,
      "sound":"ping.aiff",
      "expiry": 1423238641,
      "priority": 10,
      "contentAvailable": true,
      "payload":{
        "key1":"value",
        "key2":"value"
      }
    },
    "android":{
      "collapseKey":"foo",
      "delayWhileIdle":true,
      "timeToLive":300,
      "payload":{
        "key1":"value",
        "key2":"value"
      }
    }
  }
}

#2

I found out my self by consulting Apple’s docs on Notifications.

  1. “Expiry” is a unix timestamp (which my not be too far in the future I guess)
  2. “Priority” can have two different values. 5: The push message is sent at a time that conserves power on the device receiving it. 10: The push message is sent immediately.

After setting a valid timestamp sending push notifications started working again.

I hope my experiences will be helpful for others in the future.

P.S.: I’d suggest improving the docs by at least add the link to Apple’s docs on Notifications.