Created
July 24, 2016 14:18
-
-
Save bartjkdp/ad7331f8c23cbe20a7b2bf42323aea6a to your computer and use it in GitHub Desktop.
Send push notification through Apple Push Notification Service (APNS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$token = "<device-token>"; | |
$message = array( | |
'aps' => array( | |
'alert' => 'hi there', | |
'badge' => 1, | |
'sound' => 'default' | |
) | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3); | |
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); | |
curl_setopt($ch, CURLOPT_URL, 'https://api.push.apple.com/3/device/' . $token); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($message)); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("apns-topic: com.pleio.pleioapp")); | |
curl_setopt($ch, CURLOPT_SSLCERT, 'apns.crt'); // a file containing with the certificate and the private key concatinated | |
$response = curl_exec($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment