peal / ios-push-notification
Ios push notification using aws sns(sort notification system)
Requires
- illuminate/support: 5.6.*
This package is auto-updated.
Last update: 2025-04-14 20:26:41 UTC
README
Ios push notification in Laravel using AWS sns
Amazon Simple Notification Service (SNS) is a flexible, fully managed pub/sub messaging and mobile notifications service for coordinating the delivery of messages to subscribing endpoints and clients. With SNS you can fan-out messages to a large number of subscribers, including distributed systems and services, and mobile devices. It is easy to set up, operate, and reliably send notifications to all your endpoints – at any scale. You can get started using SNS in a matter of minutes using the AWS Management Console, AWS Command Line Interface, or using the AWS SDK with just three simple APIs. SNS eliminates the complexity and overhead associated with managing and operating dedicated messaging software and infrastructure.
Installation
Inside your project root directory, open your terminal
composer require peal/ios-push-notification
Composer will automatically download all dependencies.
For Laravel
After complete the installation, open your app.php from config folder, paste below line inside providers array
peal\iosnotification\IosServiceProvider::class,
For Facade support, paste below line inside aliases array
'IosPush' => peal\iosnotification\IosPush::class,
Then run this command
php artisan vendor:publish --provider="peal\iosnotification\IosServiceProvider"
After vendor published check your config folder aws-config.php is created.
/* * AWS config file * */ return [ 'SNS_ACCESS_KEY' => 'YOUR-SNS-ACCESS-KEY', 'SNS_SECRET_KEY' => 'YOUR-SNS-SECRET-KEY', 'SNS_APP_ARN' => 'YOUR-SNS-APP-APN', 'pushIos' => peal\iosnotification\IosPush::class, ];
USAGES
try { $ios = \App::make('IosPush'); $data = [ 'desc' => 'Ios push description', 'TargetArn' => "AWS ENPOINT(AFTER INSTALL APP IN YOUR MOBILE AN END POINT NUMBER IS GENERATED)", ]; return $ios->notificationDescription($data['desc']) ->awsEndPoint($data['TargetArn']) ->customPayLoadData("type", "Ios Push") ->customPayLoadData("cityid", "170") ->payLoadData() ->iosNotifiction(); } catch(\Exception $e) { return $e->getMessage(); }
Using Facades
use IosPush; try { $data = [ 'desc' => 'Ios push description', 'TargetArn' => "AWS ENPOINT(AFTER INSTALL APP IN YOUR MOBILE AN END POINT NUMBER IS GENERATED)", ]; return IosPush::notificationDescription($data['desc']) ->awsEndPoint($data['TargetArn']) ->customPayLoadData("type", "Ios Push") ->customPayLoadData("cityid", "170") ->payLoadData() ->iosNotifiction(); } catch(\Exception $e) { return $e->getMessage(); }
For core php
use peal\iosnotification\PushHandler\PushHandler; use peal\iosnotification\IosPush; use Aws\Credentials\Credentials; use Aws\Sns\SnsClient; try { $pios = new PushHandler(new IosPush( new SnsClient([ 'version' => 'latest', 'region' => 'us-west-2', 'credentials' => new Credentials( config('aws-config.SNS_ACCESS_KEY'), config('aws-config.SNS_SECRET_KEY') ) ]) )); $data = [ 'desc' => 'Ios push description', 'TargetArn' => "AWS ENPOINT(AFTER INSTALL APP IN YOUR MOBILE AN END POINT NUMBER IS GENERATED)", ]; return $pios->notificationDescription($data['desc']) ->awsEndPoint($data['TargetArn']) ->customPayLoadData("type", "Ios Push") ->customPayLoadData("cityid", "170") ->payLoadData() ->iosNotifiction(); } catch(\Exception $e) { return $e->getMessage(); }