Page 1 of 1

Expiry Date in Push notification using php curl

Posted: Thu Apr 21, 2016 9:27 pm
by Voltaire

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


Expiry Date in Push notification using php curl

Posted: Fri Apr 22, 2016 3:39 pm
by Serhii Kulibaba

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


Expiry Date in Push notification using php curl

Posted: Fri Apr 22, 2016 9:42 pm
by Voltaire

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;


Expiry Date in Push notification using php curl

Posted: Sat Apr 23, 2016 9:49 am
by Voltaire

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


Expiry Date in Push notification using php curl

Posted: Sat Apr 23, 2016 9:56 am
by Galyna Abramovych

Hello,

Thank you for your update! Glad it works now!