How to use firebase realtime notification in laravel? - php

I want a notification to be shown when any user posts any new message in my Android app, my iOS app, and the Web the notification should be shown to all the users who are using the app, with the message in the notification like WhatsApp notification. I am using a firebase real-time database for saving and retrieving the message.
Please let me know how I can achieve it.

First step is to get the firebase messaging sdk & credentials from firebase console.
Using that sdk, we need to get permission from user to send notification.
If the user accepts, then we get a token.
Using the acquired token, we can send notification to the user with the credentials retrieved from the firebase console.
You can see full technical blog on medium here

First step is to get the firebase messaging sdk & credentials from firebase console.
Second using Laravel-FCM is an easy to use package working with both Laravel and Lumen for sending push notification with Firebase Cloud Messaging (FCM).
https://github.com/apility/Laravel-FCM

Related

Send FCM message to specific Google user without need to install an app?

I'm doing a tiny personal project involving an Arduino and a PHP backend. I want to send a push notification from the PHP backend to my Android phone using Firebase Cloud Messaging. This question is specifically about FCM - I don't want to use any other services like Blynk, etc. I also do not want to send the notification directly from the Arduino, but rather from the PHP backend.
Can I send a FCM notification to my phone without having to create an app to receive it? I'm logged in with a Google/Gmail account on the phone, and I have no need to target any other users than myself.
Can I send a FCM notification to my phone without having to create an app to receive it?
No, this is not possible. It would open users up to some pretty hefty abuse.
In order to receive your notifications, the user must have your app installed.
Mind you, this can be a pretty minimal app, since the default implementation of FCM already displays notifications to the user if the app is not active. So really all you have to do is create an empty app that includes the Firebase Cloud Messaging SDK.

How to get the access token to register iOS device in Google API with Firebase

I am working on Firebase message implementation to my php project. I am able to get the token for Android device by using
$result = $this->guzzle->request('GET', 'https://android.googleapis.com/gcm/notification?notification_key_name=$key",$headers)
How to do the same thing for iOS? I can't able to find the exact documentation for this.
Thanks,
Sai
Please consider using Firebase FCM for messaging and notification.
There are some instructions available here for iOS and Android:
https://firebase.google.com/docs/cloud-messaging/ios/client
https://firebase.google.com/docs/cloud-messaging/android/client
Firebase FCM is replacing GCM and is the suggested approach for push notifications for Android.
Thanks,
Dinakaran

Showing notification using phpmyadmin

I have made forum app (android) it uses web services to send/retrieve data from database (phpmyadmin). Now when a new question is added then everyone using the app should get a headsup notification that there is a new question. After searching every where I found that FCM should be used but I'm not getting how to use Firebase with my existing database because I want all the data to be stored in my database and also show notification.
You can pick what Firebase features you want to use. So if you use Firebase Cloud Messaging, you don't have to use the Firebase Database. You can just stick to your own database and call out to FCM from your PHP code.
Some examples of calling FCM:
How can I send a Firebase Cloud Messaging notification without use the Firebase Console?
Send FCM messages from server side to android device
many of the results in this list

Error:Not Registered - GCM Push Notification

I have done the GCM Integration in iOS client, and i am able to push a notification from DHC - REST client. When i tried my registration token in my backend php it says Error: Not Registered.
Please help me on this, thanks in advance...
Try the following workarounds:
Make sure that the APNS token you're using to register with GCM is valid for the particular server.
Make sure that you are using the right iOS Development Provisioning Profile. Check if you're using the specific profile for your bundle name instead of a a generic one. To get push and background notifications working again:
Remove/Uninstall the application from the test device.
Perform 'clean' in XCode.
Perform 'build' in XCode.
Reinstall the app to the device.
You can check these related SO questions:
GCM IOS NotRegistered issue
GCM push fails with NotRegistered
gcm push notification: first success, then not registered in IOS
Hope it helps! :)

How to send push notification by using php to android

I'm trying to send push notification to my app from PHP server.
but I don't understand certain thing like what I need to make PHP server.
I have my app. I configured every thing.
I have created my app in phonegap.
I have API KEY, Project NO., and Registration Key.
I have follow this articles:
Google Cloud Messaging GCM for Android and Push Notifications
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL
Push notifications with PhoneGap and Android
but still not able to create php page to send notifications.
I can send notification using pushbots.
but I want to create my own PHP page to send Push notification.
Please help me with this.
I will really appreciate your help.
Thanks in advance
For a good example of PHP code that send Android push notification look at this gist.
In order to have always the updated version of registration tokens, you should write another php page that receive tokens from devices and write them in a db. Then you can get these tokens before sending push notifications.

Categories