keithslater / laravel-easyapns by keithslater

Easy APNS for Laravel. Easy APNS is an Apple Push Notification Service using PHP & MySQL
35
7
4
Package Data
Maintainer Username: keithslater
Maintainer Contact: keith@keithslater.com (Keith Slater)
Package Create Date: 2014-05-25
Package Last Update: 2014-05-25
Home Page:
Language: PHP
License: Unknown
Last Refreshed: 2024-04-15 15:14:54
Package Statistics
Total Downloads: 35
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 7
Total Watchers: 4
Total Forks: 4
Total Open Issues: 0

A Laravel package of Easy APNS

  • This is a very early beta. Use at your own risk. Please report any bugs *

Code ported from Easy APNS

Installation Instructions

Add the following to your composer.json file

"keithslater/easyapns": "dev-master"

Then run composer update

After the project is updated, add the following to your app.php file:

'providers' => array(
    'Keithslater\Easyapns\EasyapnsServiceProvider',
);

The following command runs the migration to your database

$ php artisan migrate --package="keithslater/easyapns"

This command copies the config file to app/config/packages/keithslater/easyapns/config.php

$ php artisan config:publish keithslater/easyapns

Upload your development and production .pem files to app/config/packages/keithslater/easyapns/. If you need to convert your certificates to pem certificate files, I recommend following this answer on Stackoverflow.

Modify app/config/packages/keithslater/easyapns/config.php as needed

APNS command

Finds messages in the database that are still queued and will push them. Sends only first message for device

$ php artisan apns fetch

Similar to fetch but sends all messages for each device

$ php artisan apns flush

You might want to set one of these commands as a cronjob

Usage

Add the following to the header where you are calling APNS

use \Keithslater\Easyapns\Easyapns;

Then you will be able to use Easy APNS like normal:

$apns = new Easyapns();
$apns->newMessage(1);
$apns->addMessageAlert('Test message sent');
$apns->queueMessage();
$apns->processQueue();

Refer to Easy APNS for more information.

Responding to the Apple Delegate methods

I recommend setting up a route named something similar to apns. From that route call Easyapns with all input requests. Something similar to this example:

Route::get('apns', function() {
        $apns = new Easyapns(Input::all());
});

These few lines of code will respond to the delegate method from your app and add the new device to the database. Just change the host and urlString strings in the app delegate methods to point here.