E
E
EvgMul2017-04-28 11:58:58
PHP
EvgMul, 2017-04-28 11:58:58

How to work with IOS push notification API correctly?

Hello, I'm trying to send push notifications to an ios app.
It turned out something like this code:

<?php

if(defined('CURL_HTTP_VERSION_2_0')){
    $device_token   = '3abe4507a7bca21aec0c115b06b6798d78fd55100a4898bf3c969c0a3f799466';
    $apns_topic     = 'your apns topic. Can be your app bundle ID';

    $sample_alert = '{"aps":{"alert":"hi","sound":"default"}}';
    $url = "https://api.development.push.apple.com:443/3/device/3abe4507a7bca21aec0c115b06b6798d78fd55100a4898bf3c969c0a3f799466";

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    var_dump($response);
}

?>

The request returns the following error:
@@HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 474554202f332f6465766963652f33616265343530376137
Please tell me what, where and how am I doing wrong?
Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Artamonov, 2017-05-05
@ArtamonovDenis

Try like this - https://github.com/ArtamonovDenis/Artamonov.push

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question