Amazon Simple Notification Service (Amazon SNS) is a fast, fully-managed, push messaging service. Amazon SNS can deliver messages to mobile devices (i.e. iOS, Android). It transmits push notifications from backend server applications to mobile apps on Apple, Google and Kindle Fire devices using a simple API. You can send a message to a particular device or you can send a message to every device that is subscribed to a particular SNS App.
Best of all, you can start using this feature at no charge. The AWS Free Tier means all AWS customers can send one million push notifications per month across iOS, Android and Kindle platforms at no charge. After that, you pay $0.50 for every million publishes and $0.50 per million push deliveries.
Handling Amazon SNS notification messages with PHP is simple. Here's what you need to do to create a mobile app that can receive push notifications:
<?php // Load the AWS SDK for PHP require '/aws-sdk.phar'; // Create a new Amazon SNS client $sns = Aws\Sns\SnsClient::factory(array('key' => '...', 'secret' => '...', 'region' => 'us-east-1')); // Get and display the platform applications print("List All Platform Applications:\n"); $Model1 = $sns->listPlatformApplications(); foreach ($Model1['PlatformApplications'] as $App) { print($App['PlatformApplicationArn'] . "\n"); } print("\n"); // Get the Arn of the first application $AppArn = $Model1['PlatformApplications'][0]['PlatformApplicationArn']; // Get the application's endpoints $Model2 = $sns->listEndpointsByPlatformApplication(array('PlatformApplicationArn' => $AppArn)); // Display all of the endpoints for the first application print("List All Endpoints for First App:\n"); foreach ($Model2['Endpoints'] as $Endpoint) { $EndpointArn = $Endpoint['EndpointArn']; print($EndpointArn . "\n"); } print("\n"); // Send a message to each endpoint print("Send Message to all Endpoints:\n"); foreach ($Model2['Endpoints'] as $Endpoint) { $EndpointArn = $Endpoint['EndpointArn']; try { $sns->publish(array('Message' => 'Hello from PHP', 'TargetArn' => $EndpointArn)); print($EndpointArn . " - Succeeded!\n"); } catch (Exception $e) { print($EndpointArn . " - Failed: " . $e->getMessage() . "!\n"); } } ?>
And voila! The message will appear on the device!