Laravel Firebase Push Notification to Android and IOS App Example By Hardik Savani October 30, 2021
https://www.itsolutionstuff.com/post/laravel-firebase-push-notification-to-android-and-ios-app-exampleexample.html
Last updated
Was this helpful?
https://www.itsolutionstuff.com/post/laravel-firebase-push-notification-to-android-and-ios-app-exampleexample.html
Last updated
Was this helpful?
By Hardik Savani October 30, 2021 Category : LaravelPlayUnmuteLoaded: 1.20%Fullscreen
Hi All,
In this example, you will learn laravel push notification to android and ios firebase. We will look at example of laravel firebase push notification android. i would like to show you laravel push notification android. if you want to see example of laravel push notifications ios android then you are a right place.
Today, i will give you simple example of send firebase push notification to android and ios app a using laravel. you can also use in laravel 6, laravel 7, laravel 8 and laravel 9 version.
Here, i will give you very simple step to sending push notification to android and ios app using laravel application. so basically your front-end mobile application provides you device token and you will store on database. Then you will use that device token to sending push notification using firebase laravel. so let's follow bellow steps:
Preview:
Step 1: Create Firebase Project and App
In first step, we have to go Firebase Console and create a project. then you have to create web app on that project as like i added bellow screenshot:
After created successfully created app we will go to setting page and get server api key as like bellow screen shot:
You can copy that key and add on env file as bellow:
.env
Step 2: Create Route
Here, we need to add some routes to send push notification so let's add that route in web.php file.
routes/web.php
Read Also: Laravel 8/7 Notification Tutorial | Create Notification with Laravel 8/7
Step 3: Create Controller
Here, we need add index() and sendNotification() method for admin route in NotificationController.
In sendNotification() method we will get all device token from users table and send notification to user.
now, so let's add like as bellow:
app/Http/Controllers/NotificationController.php
Step 4: Update Blade File
In this step, we will create pushNotification.blade.php file with following code:
resources/views/pushNotification.blade.php
Run Laravel App:
All the required steps have been done, now you have to type the given below command and hit enter to run the Laravel app:
Now, Go to your web browser, type the given URL and view the app output:
Read Also: How to Add Two Factor Authentication with SMS in Laravel?
I hope it can help you...