Sending Push Notifications from your web server

With thousands of mobile applications vying for your customers’ attention, Push Notifications are a great way to keep them engaged and returning to your application. From simple alerts to rich-content messages, Push is perfect for direct marketing campaigns, application updates, schedule reminders and productivity messages. You can design a push message to just deliver information, or to lead users to deeper interactions within your application.

Simply put, push messages will tune in your users, and at the same time help build brand awareness and loyalty, and create new revenue opportunities.

Now let’s discuss technical details. The most popular mobile platforms are Android and iOS.

APNs (short for Apple Push Notification service) is the centerpiece of the push notifications feature. It is a robust and highly efficient service for propagating information to iOS and OS X devices. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. If a notification for an application arrives when that application is not running, the device alerts the user that the application has data waiting for it.

Software developers (“providers”) originate the notifications in their server software. The provider connects with APNs through a persistent and secure channel while monitoring incoming data intended for their client applications. When new data for an application arrives, the provider prepares and sends a notification through the channel to APNs, which pushes the notification to the target device

Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users’ Android-powered device, and also to receive messages from devices on the same connection. The GCM service handles all aspects of message queuing and delivery to the target Android application running on the target device. GCM is completely free no matter how big your messaging needs are, and there are no quotas.

After a few hours of learning all this stuff, I wrote a PHP helper class for sending both types of push messages.

Here is the code

 

Additional links to read:

Apple Push Notification Service

Google Cloud Messaging for Android

By Roman Derevianko, PHP developer at Letzgro

 

 

[/testimonial]

Related Posts

4 COMMENTS

  1. Ceren
    February 16, 2014 22:00

    Great! Thanks.

    “GCM allows us to send a notification to up to 1000 device at a time.” please suggest me how I can achieve that.
    Thanks in Advance

  2. Ceren
    March 06, 2014 18:20

    How to catch invalid registration_id’s for update database?

  3. alberto
    October 30, 2014 18:31

    Hi
    Thank for the code.
    I am trying to implement your class in my php page (message.php).
    In my message.php page I send by POST method a message that have to be read in my APP (Android and iOS)
    What exactly I have to write to call the class?

    include(“PushNotifications.php”);

    myMessage=$_POST[‘message’];

    $classPush= new PushNotifications();
    $classPush->data($myMessage);
    $classPush->send();

    This is incorrect ?

    Thanks

  4. swapnil shah
    November 27, 2014 09:38

    Hello,

    From where I will get this 2 below variables:-

    public static $GCM_API_KEY = ‘replace with yours’;

    public static $PASS_PHRASE = ‘replace with yours’;

Leave a reply