Laravel Slack documentation? - php

I've read the page about the new notifications in Laravel 5.3, and seen some tutorials from Laracasts, but I would like to know what is available in terms of variables etc.
In the Slack API documentation, I can see that I can create buttons in the notification, however, the notification (using SlackMessage) shows that I can't use action() and it throws
Error
Call to undefined method Illuminate\Notifications\Messages\SlackMessage::action()
Does anyone have some information about this?
Thanks in advance!

What I think is you are reading the documentation wrongly. According to Laravel's Slack Notification, it doesn't help you create "button" in Slack.
The Laravel Notification is a mechanism for you to create notification through different channels, like SMS (Nexmo), Database, Emails, Slack. So if you think about this carefully, "button" is actually not a common pattern in these channels, hence action is not implemented here in Slack.
In contract, the action method found in SimpleMessage or MailMessage is actually referring to "call-to-action" button. It helps you create a button in the email nicely. This is not true in other type of notifications, such as DatabaseMessage, NexmoMessage, or SlackMessage. You simply don't (or doesn't make sense) to create buttons in these channels.
If you need to create additional content with SlackMessage, simply extend it and build one for your own.

Related

Opencart3: How is implemented email notifications

In Opencart 1.5.X email notifications for new order\customers\etc was implemented via catalog/model/checkout/order.php in confirm() method.
But in OC3.X this code was completely rewrited and I can not find how this functionality is implemented in this version.
Your list of notifications implements in different places. Email notifications mostly implements in /catalog/controller/mail/
There you can find affiliate, forgotten, order, register and transaction.
Each controller related to one or more different models. You can find a related models using search in these controller, looking for $this->model_.
For example /catalog/controller/mail/order.php contains references mostly on /catalog/model/checkout/order.php ($this->model_checkout_order).

How to modify Firebase push notification

I am sending push notification form my server API to ios devices using google's Firebase push notification.
Right now when user receives it its structure is simple, there is a title and a message.
Can I add custom buttons in it? For example two buttons, one to accept the action and the other to reject it.
I have read the documentation but I could not find anything concerning code.
I know I am stating my problem straight away here.
Can somebody please guide me in this?
Thank You

Laravel Broadcasting: Notification vs Event

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..

Php button push notification android

I'm trying to implement push notification but I'm a little bit lost.
I just want to have a button in php and when I click it, a notification appear in all devices telling the users something like: "A new image is available in the web".
I read the GCM documentation but I'm not sure how to start.
I see that in some examples the users have to send their emails in order to register their "sender id"? it is necessary? I want the user don't have to register anywhere.
Can someone help me to start or give me a quick tutorial?
Thank's for all.
You will need to use curl to call the GCM, you can find examples like this all over SO, for example : how to send a notification to millions of android devices in php using GCM (first one that came up in a search)
And of course you will need the registration id's otherwise GCM doesznt know which device to send the notification to.
The solution is not so simple. You should at least use some package dedicated to this specific service. Also, you should read something about what push notifications are.
There are many services out there you can use to interface yourself with this specific kind of service.
Take a look to this service to get a first idea about the entire mechanism. Remember that you have to subscribe to a push service provider for every platform you want to use. For example the Apple Push Notification Service, or Cloud Messaging by Google.
Hope it's a good start for you.

how to send push notifications to multiple users via php

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.

Categories