Voltaire
Posts: 0
Joined: Thu Apr 09, 2015 8:48 pm

Expiry Date in Push notification using php curl

The following script was working fine even if the device was offline it will receive the message when going online, now if the device is offline the push notification won't arrive when the device is online. It seems that we need to specify the Expiration date !!.
I am using the following script how can I include the Expiration date request :

$url = "https://api.appery.io/rest/push/msg";
$message1 = '{"payload":{"message":"'.$message.'","badge":"1"},"status":"sent"}';
$headers = array('X-Appery-Push-Master-Key: xxxxxx-xxxxxx-xxxxx','Content-type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $message1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
$result = curl_exec($ch);

Where to include the Expiration date please ?
Thanks in advance

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Expiry Date in Push notification using php curl

Hello,

This is something outside the scope (http://devcenter.appery.io/support-po...) of our standard support.

But I'll try to help you. Please add a parameter "expirationTime" to your variable "$message1":
pre$message1 = '{"payload":{"message":"'.$message.'","badge":"1"},"status":"sent", "expirationTime":"2016-04-22T15:39:02.273Z"}';/pre

Voltaire
Posts: 0
Joined: Thu Apr 09, 2015 8:48 pm

Expiry Date in Push notification using php curl

Thanks a lot for the reply, I appreciate it.
I will test it this weekend and will get back the result in case someone else is facing the same problem.
Regards;

Voltaire
Posts: 0
Joined: Thu Apr 09, 2015 8:48 pm

Expiry Date in Push notification using php curl

It worked thanks still with a minor modification , and just in case someone was looking for the script, I used the following:

I defined the expiration time to be after one day @ midnight

code
$d=strtotime("tomorrow");
$date1= date("Y-m-d", $d);
$date2 = $date1. " 23:59:59.237Z&quot

$url = "https://api.appery.io/rest/push/msg&quot
$message1 = '{"payload":{"message":"'.$message.'","badge":"1"},"status":"sent", "expirationTime":"'.$date2.'"}';
/code

Thanks again for the support

Galyna Abramovych
Site Admin
Posts: 84
Joined: Tue Mar 22, 2016 6:03 pm

Expiry Date in Push notification using php curl

Hello,

Thank you for your update! Glad it works now!

Return to “Issues”