Download the PHP package alxmsl/apnsclient without Composer

On this page you can find all versions of the php package alxmsl/apnsclient. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package apnsclient

APNSClient

Client for Apple Push Notification Service (APNS)

Standard payload creation

// Create simple alert item
$SimpleItem = new \APNS\Notification\AlertItem();
$SimpleItem->setBody('просто уведомление');

// Create simple payload
$SimplePayload = new \APNS\Notification\BasePayload();
$SimplePayload->setAlertItem($SimpleItem);

// Look at simple payload
var_dump((string) $SimplePayload);

Localized payload creation

// Create localized alert item
$LocalizedItem = new \APNS\Notification\AlertItem();
$LocalizedItem->setLocalizedKey('GAME_PLAY_REQUEST_FORMAT')
    ->setLocalizedArgs(array(
        'Jenna',
        'Frank',
    ));

// Create localized payload
$LocalizedPayload = new \APNS\Notification\BasePayload();
$LocalizedPayload->setAlertItem($LocalizedItem);

// Look at localized payload
var_dump((string) $LocalizedPayload);

Custom payload creation

// Create custom payload class
final class CustomPayload extends \APNS\Notification\BasePayload {
    /**
     * @var null|string custom field
     */
    private $acme = null;

    /**
     * @param string|null $acme custom parameter value if needed
     * @return CustomPayload self
     */
    public function setAcme($acme) {
        $this->acme = (string) $acme;
        return $this;
    }

    /**
     * @return null|string custom parameter if set
     */
    public function getAcme() {
        return $this->acme;
    }

    /**
     * JsonSerializable implementation
     * @return array payload json serializable instance
     */
    public function jsonSerialize() {
        $result = parent::jsonSerialize();

        if (!is_null($this->getAcme())) {
            $result['acme'] = (string) $this->getAcme();
        }
        return $result;
    }
}

// Create simple alert item
$SimpleItem = new \APNS\Notification\AlertItem();
$SimpleItem->setBody('You got your emails.');

// Create payload instance
$CustomPayload = new CustomPayload();
$CustomPayload->setAcme('foo')
    ->setAlertItem($SimpleItem)
    ->setBadgeNumber(9)
    ->setSoundFile('bingbong.aiff');

// Look at payload
var_dump((string) $CustomPayload);

Send notification

// Create APNS notification client
$Client = new \APNS\Notification\Client();

// Set secure certificate filename
$Client->setCertificateFile('certificate.production.pem');

// Create needed alert item
$Item = new \APNS\Notification\AlertItem();
$Item->setBody('test1');

// Create payload
$Payload = new \APNS\Notification\BasePayload();
$Payload->setAlertItem($Item)
    ->setBadgeNumber(1)
    ->setIdentifier(time());

// Send notification to the device
$result = $Client->send('c0RreCtT0kEN', $Payload);
var_dump($result);

Use the feedback service

// Create APNS notification client
$Client = new \APNS\Feedback\Client();

// Set secure certificate filename
$Client->setCertificateFile('certificate.production.pem')
    ->setProtocolSchemeSSL();

$Client->process(function ($time, $token) {
    echo date('Y-m-d H:i:s', $time) . ' - ' . $token . "\n";
    return true;
}, false);

var_dump(
    $Client->getReadCount(),
    $Client->getProcessedCount(),
    $Client->getUnprocessedCount(),
    $Client->getErrorCount()
);

License

Copyright © 2014 Alexey Maslov [email protected] This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.


All versions of apnsclient with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alxmsl/apnsclient contains the following files

Loading the files please wait ...