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

 

Installation

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(
    ...
    'DavibennunLaravelPushNotificationLaravelPushNotificationServiceProvider'
)

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 gonative.io. 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);
    PushNotification::app(‘ios’)
    ->to($devices)
    ->send($push_message);

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

  • Anju PS

    Hi
    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

      PushNotification::app(‘Testapp’)
      ->to($deviceToken)
      ->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..

Pin It on Pinterest

Shares