Simplified APNS (Apple Push Notification Service)

FREEMIUM
By InfiniteLoop.ie | Updated hace 10 días | Communication
Health Check

N/A

README

By March 31st 2021, Apple will discontinue it’s legacy HTTP/1 (binary format) APNS API, you will need to upgrade to the HTTP/2 version before that deadline.

This API uses HTTP/2 and Apple’s new APNS API endpoints, so it will continue to work after the March 31st deadline. It offers both production and sandbox functionality, and is greatly simplified for ease of use.
You simply post, in JSON, the destination (APNS token), the message you want to appear on the user’s screen, and a Base64 encoded version of the P12 certificate, and it’s password to this API.

If you’re using C#, then the code would be something like;

public static string Push(string destination, string message, string certFile, string certPassword)
{
var certificate = File.ReadAllBytes(certFile);
var oPayload = new
{
destination,
message,
certificate,
certPassword
};
var strPayload = JsonConvert.SerializeObject(oPayload, Formatting.Indented);
var wc = new WebClient();
var response = wc.UploadString(“https://…”, strPayload);
return response;
}

or, if you’re using PHP, then the code would be;

data=filegetcontents(cert.p12);data = file_get_contents('cert.p12'); cert64 = base64_encode(data);data); destination = “-apns-token-”;
password="certpassword";password = "-cert-password-"; url = “https://xxxxxxxxx”;
ch=curlinit(ch = curl_init(url);
$oPayload = array(
‘destination’ => $destination,
‘message’ => ‘hello there!’,
‘certificate’ => $cert64,
‘certPassword’ => password);password ); payload = json_encode(oPayload);curlsetopt(oPayload); curl_setopt(ch, CURLOPT_POSTFIELDS, payload);curlsetopt(payload); curl_setopt(ch, CURLOPT_RETURNTRANSFER, true);
content=curlexec(content = curl_exec(ch);
if (content === false) { echo 'Curl error: ' . curl_error(ch);
}
curl_close($ch);
echo $content;

Followers: 0
Resources:
Product Website Terms of use
API Creator:
Rapid account: Infinite Loop Ie
InfiniteLoop.ie
dananos
Log In to Rate API
Rating: 5 - Votes: 1