I have created a dashboard using PHP and Wordpress, the problem i'm facing now is that I need to create an alert or a message when ever a new data has arrived in any users dashboard. So, I need to send the users that are currently online in the dashboard, a notification that a new data has arrived for them.
Whenever a data has been added by me for a particular user, an automatic notification should be shown on the that users screen if he is online. I have created the dashboard, but I don't know how to implement this notification.
In short, I want to create something like a push notification inside my website.
Use Atmosphere framework for braodcasting any messages. This essentially uses Websockets in the implementation. But its very easy to do.
Related
I'm currently working on a laravel app.
The same app is already running on wordpress and through the laravel application we are going to add some additional features in original application.
The laravel will run on the subdomain.
Here is the thing:
On wordpress website, we are publishing different public articles but on the publishing of these articles we need to send an email to either "all employees" of company or "all managers" of the company.
The company employees detail is stored and available in laravel.
I was hoping that there'll be a way through which on article publishing, I will give two options to the user on wordpress: "Send email to employees"/"send email to managers" and on selection of any of the option, email send event will be triggered from my laravel website.
I've almost no experience of wordpress. I was trying to google it but couldn't find any helpful links.
WordPress works quite different then laravel, and is working with many hooks..
You could monitor post status changes with: https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
You have to implement the email sending your self inside this hook,
And also trigger a webhook against your laravel endpoint.
The publish button in wordpress does not allow you to select who to send an email.., But this can be build with custom fields / meta data on your post.
Quite depends on how you would like to implement that.
Unfortunaly WordPress does not work with composer by default therefore you don't have an easy way to get packages like Guzzle to send your request to your larvel endpoint.
WordPress has some build in methods to do REST calls, see:
https://developer.wordpress.org/reference/functions/wp_remote_request/
I would like to create a social proof plugin for my wordpress application so that when users are logging in, other online users will see a pop up notification showing the user that logged in and their geolocation via googlemaps. The closest thing I could find to what I was looking for was on https://wpfomify.com.
Does anyone have any idea the steps I would take to creating a plugin like this particularly how the site will communicate to online users that a new notification has been queued. Thanks.
I read laravel documentations about Events and Notifications, it seems we can fire an event and from that event (using ShouldBroadcast interface) broadcast it to laravel echo which i understand, in the other hand we can use Notifications viaBroadcast to do the same, so what's the difference?
What the provided answer lacks imo is that they are in most cases used both instead of 1 or the other, which seems to be the tone of the provided answer/question.
An event is something significant in your application. Let's assume your application is a Webshop.
A significant action in your webshop can be Product Purchased . When a product is purchased you need to do a lot of different steps. Putting this all inside a controller and potentially in several different places can get very messy and not clear.
So a good approach would be to use a Event called ProductPurchased . This event can have Listeners, those listeners are in this case all the steps you need to perform when a user purchases a product.
e.g.:
ProductPurchased (event)
BillClient (eventlistener)
GenerateInvoice (eventlistener)
notifyClient (eventlistener)
...
Let's say we want to notify our client with a text-message and an email when they purchased a product.
So on the notifyClient event-listener we can create a Notification . This notification is responsible for sending a message to the client. This can be a SMS/Slack-message/Email/...
And like you mentioned both Events and Notifications can be put on the Queue or can be broadcasted. Broadcasting is mainly used in combination with Laravel Echo and the use of Websockets.
You choose notifications when you want to send something to different channels. Mail/SMS/Slack..
If you only need broadcasting you can just use ShouldBroadcast. Just like when you only want to send an e-mail use Mail:: without the need for a notification.
Notifications are a nice way to group the same 'message' to different destinations.
After thinking a lot, i found out that they are made for different things, here's what i understood:
Notifications:
Consider facebook, everytime you login you see bunch of notifications about things that happened while you where away, also if you are present you see live notifications..
meanwhile you're getting emails about notifications that you want..
this is exactly what Laravel Notifications is doing.
you can use notify method on your eloquent models such as App\User about something like OrderApproved which will do whatever you planned it to do for you like sending sms to that user. and also you can save one instant of that notification on database so when user comes back he or she can see that you have approved their order..
Events:
it's when something happens, like when a new user is created and you want to do different things like sending verification email, sending verification sms and.. this is why you create an event so that you could handle different logics of that event using listeners.
when it comes to broadcasting, you can use ShouldBroadcast interface on your event and from there you can sync data with your admin panel that a new user is registered. this will be useful when admin is watching list of users and without reloading the page you could user Laravel Echo to receive that event on admin panel and append new registered user to the list.
Conclusion:
it really depends on what you need, if you just want to update something in your interface, maybe events are what you need. but if you need to do more you can use notifications.
in the end events are used when you need to do things when something happens while notifications are report of what just happened.
hope it help others..
We have firebase chat application (check any chat example or tutorial) that will have same copy as our.
We would like to sent email notification or sms message, if user hasn't seen the chat message yet.
We can connect to firebase database with php and check all the messages, if they are seen or not. but It's not really proper way of doing it.
Does anyone have idea how we can implement that, so we can track of all the messages and if they haven't seen it, then sent the email / sms notification based on user preference?
I just want to know how we can do that with firebase. if it was just php and mysql. it was really easy to do this.
Not sure if this can be done efficiently in Firebase. You will have to setup a cron job to fetch the messages which are not seen and trigger SMS/Email fallback.
I would recommend using Applozic (https://www.applozic.com) for Chat related stuff and Firebase for storing user meta data and other data.
Applozic provides a single click configuration to enable Webhook/SMS/Email fallback, along with that you will get all the whatsapp like chat features along with full UI with no need to write any additional code.
I am following this tutorial from androidhive. http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Everything is working But The tutorial only shows how to send a push to ONE device at a time. I would like to send a push notification to all devices at once using the same method. I believe the way to do this is by editing the send_message.php But i'm still trying to understand how his method works.
I have tried commenting and emailing the person who wrote the article but have not gotten a response. I just need someone to point me in the right direction.
Any hints, guildance, answers, comments are much appreciated.
Now that you have successfully implemented what that tutorial teaches, the basis idea now for sending to multiple users will be something like this:
To send push notification to multiple users, you need to create an application server in PHP.Your application server will receive the registration id from the android application and will store it in a database (may be mysql).
Now when you want to send the message to the application then you write a message and fetch all the registration ids from the database which was stored earlier.
You can follow this useful tutorial to achieve exactly what you want.
The tutorial which you have mentioned was made using GCMRegistrar which is deprecated now.Instead you need to use GoogleCloudMessaging API.The link which i provided uses the new way.Hope this helps you to implement what you want.