Skip to content
A Apple Push Notification Service bundle for Laravel
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
libraries
README.md
start.php

README.md

SimpleApns

A Apple Push Notification Service bundle for Laravel

##Instalation

###Artisan

php artisan bundle:install simpleapns

###Manually

https://github.com/fabiorphp/laravel-simpleapns

##Bundle Registration

Add the following code to your application/bundle.php file:

'simpleapns' => array('auto' => true),

##Configuration

Move the config/simpleapns.php to the application folder and add the following to your application/config/simpleapns.php file:

return array(
	'local' => array(
		'host'	=> 'gateway.sandbox.push.apple.com:2195',
		'cert'	=> path('app').'certificates/dev.pem',
		'pass'	=> 'OPTIONAL PASSPHRASE', // Used when generating the *.p12 file
	),
	'prod'	=> array(
		'host'	=> 'gateway.push.apple.com:2195',
		'cert'	=> path('app').'certificates/prod.pem',
		'pass'	=> 'OPTIONAL PASSPHRASE', // Used when generating the *.p12 file
	)
);

##Usage

Instance:

$apns = SimpleApns::make();
//or
$apns = new SimpleApns;

Custom configuration:

$apns = SimpleApns::make(
	array(
		'host' => 'gateway.sandbox.push.apple.com:2195',
		'cert' => 'yourcertificate.pem',
		'pass'	=> 'OPTIONAL PASSPHRASE', // Used when generating the *.p12 file
	)
);

Send a message:

try
{
	$apns->send(
		array(
			'alert' => 'Alert!',
			'badge' => '2',
			'sound' => 'default' // Not required
		),
		'device_token' // xdigits
	);
}
catch(SimpleApns\SocketException $e)
{
	echo $e->getMessage();
}
catch(SimpleApns\ValidationException $e)
{
	print_r($e->get());
}

Questions @fabiorphp

You can’t perform that action at this time.