send push notifications to mobile devices with laravel

In this article i will talk about sending pushing notifications to mobile devices with laravel ! i will be doing this by using a laravel package called Laravel Push Notification which allows us send push notication ! one good thing baout this package is that it supports both Laravel 5 & Lumen framework so lets get started



Update your composer.json file to include this package as a dependency

Laravel 5 & Lumen

"davibennun/laravel-push-notification": "dev-laravel5"

Laravel 4.*

"davibennun/laravel-push-notification": "dev-master"

Register the PushNotification service provider by adding it to the providers array.

'providers' => array(

Alias the PushNotification facade by adding it to the aliases array in the app/config/app.php file.

'aliases' => array(
    'PushNotification' => 'DavibennunLaravelPushNotificationFacadesPushNotification'

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

  • Mocha Dwi

    You are awesome, always gave us something new to learn :) thank you Deven!

    • Deven Rathore

      welcome & keep supporting

  • Sajer2 Suka2

    Hi I am a new comer and still learning. I have applied this tutorial very carefully but I am getting error of MismatchSenderId. but i find no where did in the tutorial set the SenderId. Please enlighten me for this as it has been a week already that I am looking into this. Thank you very much.
    FYI: I am developing all in Laravel 5 and simply convert it to .apk using mobile push notification is possible using this way, right?

    • Deven Rathore

      please share your error screenshot

  • Слава Фоменко

    When I sent a collection messages, like this

    $devices = PushNotification::DeviceCollection($devices);

    If one device has bad token, all another devices don’t receive push (
    How can I resolve this problem?

  • Anju PS

    I am planning to use this library. before that I have few concerns;

    How can I set action for the push notification . ie; On clicking the notification it should open app page ( GooglePlay link for Android and AppStore link for iOS )

    • Deven Rathore

      ->send(‘insert your message & url here’);

  • Yong Jian Keong

    FatalErrorException in OptionsResolver.php line 167:syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{‘ or ‘$’

    I always getting this error when I trying to push the notification..Kindly help.. Thanks in advance..

  • aimen

    where are you getting the device token from? in a dynamic way how would you know the device token of the recipient?

  • The Brain™

    Where are you getting $deviceToken?

  • Prince

    Hello, owner!
    It is possible to send the push notification via FCM.
    Now your tutorial is used for GCM.
    I’d like to send the push notification via FCM. possible?

  • I have the same problem as @disqus_MRXpRd6Y8s:disqus because the protocol used is FCM because it is firebase and not GCM.
    How can I solve this? @deven_rathore:disqus

Pin It on Pinterest