Git Product home page Git Product logo

apns-http2's Introduction

apns-http2

Requires Curl with HTTP2 and SSL support.

Usage example:

<?php
    use Nfilin\Libs\ApnsHttp2 as Apns;

    /* Create APNS certificate */
    $certificate = new Apns\Certificate('/path/to/certificate', 'pass_phrase');

    /* Create connection */
    $connection = new Apns\Connection($certificate, [ 'sandbox' => false  ]);

    /* Create payload */
    $payload = new Apns\Payload();
    $payload->title = 'Alert title';
    $payload->custom_data['some_custom_data_key'] = 'some data';
    $payload->badge = 1;

    /* Wrap list of receivers to recognizable format */
    $receivers = new Apns\DeviceList(
                [
                    'notification_id_of_first_receiver',
                    'notification_id_of_second_receiver',
                    //...
                ]
            );

    /* Create message for seklected receivers and payload */
    $message = new Apns\Message($receivers, $payload);

    /* Sign message with topic valid for selected receivers */
    $message->topic = 'some.example.app';

    /* Set expire time in seconds from current time */
    $message->time_to_live = 3600; // One hour after been sent

    /* Send notifications and get responses */
    $response = $connection->send($message);

apns-http2's People

Contributors

andho avatar arubacao avatar necrofilin avatar smarkovskyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

apns-http2's Issues

How work

How do I get it working? just copy it smoothly to storage?
Fatal error: Uncaught Error: Class 'Nfilin\Libs\ApnsHttp2\Certificate' not found in

APNs Response status 400 and 'MissingTopic' reason

Switching to production mode (sandbox = false and the certificate) i get the following response:

[response] => Nfilin\Libs\ApnsHttp2\CurlResponse Object ( [reason] => MissingTopic [timestamp] => [status] => 400 )

reading the docs i think it may be related to:

The appropriate encoding to employ for the apns-id, apns-expiration, and apns-collapse-id request headers differs depending on whether it is part of the initial or a subsequent POST operation, as follows:
The first time you send these headers, encode them with incremental indexing to allow the header names to be added to the dynamic table
Subsequent times you send these headers, encode them as literal header fields without indexing.

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html

Someone can guide me?, if I am doing something wrong or how to solve this?.
In sandbox mode works fine.

in this thread APS : missing topic mentions differences between development and production certificates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.