laravel-notification-channels / pushover Goto Github PK
View Code? Open in Web Editor NEW๐ฑ Pushover notifications channel for Laravel
Home Page: http://laravel-notification-channels.com
License: MIT License
๐ฑ Pushover notifications channel for Laravel
Home Page: http://laravel-notification-channels.com
License: MIT License
I encountered this deprecated warning when testing the notification channel from tinker:
PHP Deprecated: is_file(): Passing null to parameter #1 ($filename) of type string is deprecated in C:\laravel-project\vendor\laravel-notification-channels\pushover\src\Pushover.php on line 124
Is this an actual warning or is it from my coding mistake? I'm on PHP8.1
Pushover added support for image pushing January of this year. https://updates.pushover.net/post/170043375237/pushing-images-with-pushover-30
It would be great to support this in the package.
Are you planning to release this for Laravel 5.4?
Hi, is there a way to send the message to only one device ?
Hi,
Upgraded to Laravel 6 a while ago and suddenly noticed my notifications arent working. I cannot figure out why. The classes are imported in my Notificaton:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Pushover\PushoverChannel;
use NotificationChannels\Pushover\PushoverMessage;
class PaymentCompleted extends Notification implements ShouldQueue
Error:
Driver [NotificationChannels\Pushover\PushoverChannel] not supported.
I can't figure out why the hell it's throwing this error suddenly. Any ideas?
I'm using Laravel 5.8 and the installation fails:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove symfony/translation v4.3.3
- Conclusion: don't install symfony/translation v4.3.3
- .............................
Please help.
My application doesn't throw errors, the e-mail is sent but I do not get a push notification on my phone. I can't find any logs anywhere, how should I proceed to fix this?
User.php (Added at the end of file)
public function routeNotificationForPushover()
{
return env('PUSHOVER_USERKEY');
}
App/Notifications/PaymentCompleted.php
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Pushover\PushoverChannel;
use NotificationChannels\Pushover\PushoverMessage;
class PaymentCompleted extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct()
{
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return ['mail', PushoverChannel::class];
}
/**
* Get the Pushover representation of the notification.
*
* @param mixed $notifiable
*
* @return \NotificationChannels\Pushover\PushoverMessage
*/
public function toPushover($notifiable)
{
return PushoverMessage::create('The invoice has been paid.')
->title('Payments')
->sound('incoming')
->normalPriority();
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage())
->greeting('Hello!')
->line('Your payment has been successfully processed.')
->action('View account', 'https://DOMAIN/profile')
->line('tetstststststetst!');
}
}
App/Http/Controllers/BlablaController.php
public function notify()
{
$user = User::find(1);
$user->notify(new PaymentCompleted());
}
According to the api docs you must send both the user and the token parameters. https://pushover.net/api
This code only appears to require the token which is then past as the user parameter.
If I change my routeNotificationForPushover to
public function routeNotificationForPushover() { return ['user' => $this->pushover_user, 'token' => $this->pushover_token]; }
It does appear to put the correct params into the url that is past to pushover. However doing this then gives me the error
FatalThrowableError in PushoverChannel.php line 50: Call to a member function toArray() on array
I have an empty to array function on the notification call which appears not to get used. The code looks for toArray on the PushoverChannel class.
Laravel 10 has recently been released, it would be great if this package could be updated to support this. Note that we appear to currently have no support for Laravel 9.:(
I'm in need of a way to send multiple notifications for a single notifiable. I am familiar with Group notifications but that will not work for my use case.
I've accomplished this by making some modifications to the PushoverChannel@send method but I'm not too good with writing tests (Still working through Adam's Test Driven Laravel).
Basically I'm converting the routeNotificationFor
response to an array and then looping over them and sending a notification to each one. The details section below shows the code for the send method.
I wasn't sure if I should create a PR, since it wouldn't have tests.
Thanks for taking a look.
public function send($notifiable, Notification $notification)
{
if (! $pushoverReceivers = $notifiable->routeNotificationFor('pushover')) {
return;
}
$pushoverReceivers = is_array($pushoverReceivers) ? $pushoverReceivers : [$pushoverReceivers];
foreach( $pushoverReceivers as $pushoverReceiver ){
if (is_string($pushoverReceiver)) {
$pushoverReceiver = PushoverReceiver::withUserKey($pushoverReceiver);
}
$message = $notification->toPushover($notifiable);
try {
$this->pushover->send(array_merge($message->toArray(), $pushoverReceiver->toArray()));
} catch (ServiceCommunicationError $serviceCommunicationError) {
$this->fireFailedEvent($notifiable, $notification, $serviceCommunicationError->getMessage());
}
}
}
Hi,
Can you please tag a release on the newest laravel version? I'm currently using dev-master but prefer to have versions.
In src/PushoverChannel.php the $this->events->fire() call seems to have been deprecated and removed in Laravel 5.8.
Not sure if it was added later again at some point, as this package I think was working in a Laravel 7.x app, but it is currently failing with laravel Method Illuminate\Events\Dispatcher::fire does not exist.
in 7.25.0 at least.
Not sure if there is any reason not to change this to dispatch(), since older 5.x appears to longer be supported. The change done manually works for me at the moment.
Removal Reference: laravel/framework#26392
Thanks!
Hi, I'm deploying my project from homestead on Ubuntu 16.04, ngnix, php7. Everything is working correct, but pushover doesn't send notifications. On local homestead server everything works. Please help me to solve this problem.
This is my Route:
Route::get('n', function () {
$user = App\User::first();
$bid = App\Bid::first();
$user->notify(new NewBid($bid));
});
This is my Push:
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Pushover\PushoverChannel;
use NotificationChannels\Pushover\PushoverMessage;
class NewBid extends Notification implements ShouldQueue
{
use Queueable;
protected $bid;
public function __construct($bid)
{
$this->bid = $bid;
}
public function via($notifiable)
{
return [PushoverChannel::class];
}
public function toPushover($notifiable)
{
return PushoverMessage::create($this->bid->name .' โ ' .$this->bid->phone)
->title('example.com')
->sound('incoming')
->normalPriority()
->url('http://example.com/invoices', 'Go to Link');
}
}
This is from my config/services.php:
'pushover' => [
'token' => 'Here I'm using my token for application',
],
Please help!
Laravel 9 has been released and we need to update this repo to support it.
Hello,
I'm attempting to send a Pushover notification from a test route just to ensure I'm happy with the formatting.
$user = GrimeArchive\User::first();
\NotificationChannels\Pushover\PushoverMessage::create($user->name . ' registered for Grime Archive')
->title('New user registration: Grime Archive')
->sound('incoming')
->lowPriority()
->url(route('users.show', $user), 'Visit Profile');
dd('notified');
Simply getting the first user, and sending a message as per the documentation.
I've installed, added the service provided to my config/app.php
and configured my token in config/serivces.php
;
'pushover' => [
'token' => env('PUSHOVER_TOKEN'), // this is obviously in my .env file
],
I've triple checked everything - I think I've got everything set up correctly but I'm not receiving any notifications at all (to neither of my 3 devices I have registered on Pushover).
I also don't receive any errors when I hit my test route, I see notified
dd()'d as per my example above.
Hope you can help :)
Hi there! I am pretty new to Laravel Notifications so I may also have missed a point.
I saw that notifications can be sent on-demand and wanted to do this in my application with the Pushover channel. Thing is, that I do want to send myself a notification; a single user token is supplied via the .env file as I do not want to store one single key in the database or somewhere else.
So, I thought I could just do something like
Notification::route('pushover', config('services.pushover.user_token'))
->notify(new SomePushoverNotification($text, $message, $priority));
but I get the following error:
Illuminate\Contracts\Container\BindingResolutionException:
Unresolvable dependency resolving [Parameter #1 [ <required> $token ]] in class NotificationChannels\Pushover\Pushover
Sound like the token is not being handed to the Pushover Channel or something?
However, using the Pushover channel for the laravel-backup package works fine, which uses a custom notifiable class that has just a routeNotificationForPushover
method:
public function routeNotificationForPushover()
{
return PushoverReceiver::withUserKey(config('services.pushover.user_token'));
}
What am I doing wrong? :/
Support should be added for Laravel 5.8. If no one else can, I'll try to take a look at it when I can find the time.
Laravel 8 has been released today and we need to update this repo to support it.
See https://laravel.com/docs/8.x/upgrade & laravel-notification-channels/channels#107
When running composer require laravel-notification-channels/pushover
version 1.1.0 gets installed which does not support Laravel 5.5
The latest release which does support Laravel 5.5 has a lower version (1.0.2). Manually installing this version does off course works. Probably something went wrong naming this release.
Hi there!
Laravel requires Guzzle 7, but this package requires Guzzle 6. This is preventing me from updating to Laravel 8:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for laravel-notification-channels/pushover ^2.1 -> satisfiable by laravel-notification-channels/pushover[2.1.0, 2.1.1, 2.1.2].
- Can only install one of: guzzlehttp/guzzle[7.0.1, 6.5.x-dev].
- Can only install one of: guzzlehttp/guzzle[7.0.x-dev, 6.5.x-dev].
- Can only install one of: guzzlehttp/guzzle[7.1.x-dev, 6.5.x-dev].
- Conclusion: install guzzlehttp/guzzle 6.5.x-dev
- Installation request for guzzlehttp/guzzle ^7.0.1 -> satisfiable by guzzlehttp/guzzle[7.0.1, 7.0.x-dev, 7.1.x-dev].
I noticed the Laravel 8 PR has been merged without updating Guzzle.
Might I ask why Guzzle is still on 6?
@casperboone Ping me when ready, then I'll do a code review
Please, add support for on-demand notifications (without Notifiable object). See https://laravel.com/docs/8.x/notifications#on-demand-notifications
It should work like:
\Notification::route(PushoverChannel::class, '4fefd4acsad5f4de8f')
->notify(
new MyNotification()
);
If possible, please, backport it also to 2.0
version. Thanks.
Using Laravel 5.8 I get this when trying to install:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel-notification-channels/pushover 1.2.3 requires nesbot/carbon ^1.21 -> satisfiable by nesbot/carbon[1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.25.1, 1.25.3, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.26.5, 1.26.6, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.37.0, 1.37.1, 1.38.0, 1.38.1, 1.38.2, 1.38.3, 1.38.4] but these conflict with your requirements or minimum-stability.
- laravel-notification-channels/pushover 1.2.2 requires nesbot/carbon ^1.21 -> satisfiable by nesbot/carbon[1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.25.1, 1.25.3, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.26.5, 1.26.6, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.37.0, 1.37.1, 1.38.0, 1.38.1, 1.38.2, 1.38.3, 1.38.4] but these conflict with your requirements or minimum-stability.
- laravel-notification-channels/pushover 1.2.1 requires nesbot/carbon ^1.21 -> satisfiable by nesbot/carbon[1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.25.1, 1.25.3, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.26.5, 1.26.6, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.37.0, 1.37.1, 1.38.0, 1.38.1, 1.38.2, 1.38.3, 1.38.4] but these conflict with your requirements or minimum-stability.
- laravel-notification-channels/pushover 1.2.0 requires nesbot/carbon ^1.21 -> satisfiable by nesbot/carbon[1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 1.24.1, 1.24.2, 1.25.0, 1.25.1, 1.25.3, 1.26.0, 1.26.1, 1.26.2, 1.26.3, 1.26.4, 1.26.5, 1.26.6, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.37.0, 1.37.1, 1.38.0, 1.38.1, 1.38.2, 1.38.3, 1.38.4] but these conflict with your requirements or minimum-stability.
- Installation request for laravel-notification-channels/pushover ^1.2 -> satisfiable by laravel-notification-channels/pushover[1.2.0, 1.2.1, 1.2.2, 1.2.3].
Installation failed, reverting ./composer.json to its original content.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.