Skip to content

Commit

Permalink
Fix image url in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Oct 15, 2024
1 parent 56b3f92 commit 3c29d34
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
3 changes: 1 addition & 2 deletions driver/Fcm.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use humhub\modules\fcmPush\components\SendReport;
use humhub\modules\fcmPush\models\ConfigureForm;
use humhub\modules\fcmPush\Module;
use humhub\modules\notification\models\Notification as NotificationHumHub;
use Kreait\Firebase\Contract\Messaging;
use Kreait\Firebase\Exception\FirebaseException;
use Kreait\Firebase\Exception\MessagingException;
Expand Down Expand Up @@ -34,7 +33,7 @@ public function processCloudMessage(array $tokens, string $title, string $body,
}

$message = CloudMessage::new()
->withNotification(Notification::create($title, $body))
->withNotification(Notification::create($title, $body, $imageUrl))
->withWebPushConfig(['fcm_options' => ['link' => $url]])
->withData(['url' => $url, 'notification_count' => $notificationCount]);

Expand Down
7 changes: 3 additions & 4 deletions driver/FcmLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
namespace humhub\modules\fcmPush\driver;

use humhub\modules\fcmPush\components\SendReport;
use humhub\modules\web\pwa\widgets\SiteIcon;
use humhub\modules\fcmPush\models\ConfigureForm;
use Yii;
use yii\httpclient\Client;
use humhub\modules\fcmPush\models\ConfigureForm;

class FcmLegacy extends Client implements DriverInterface
{
Expand Down Expand Up @@ -34,13 +33,13 @@ public function processCloudMessage(array $tokens, string $title, string $body,
"notification" => [
"title" => $title,
"body" => $body,
"icon" => SiteIcon::getUrl(180),
"icon" => $imageUrl,
"click_action" => $url,
],
"data" => [
"title" => $title,
"body" => $body,
"icon" => SiteIcon::getUrl(180),
"icon" => $imageUrl,
"url" => $url,
],
"registration_ids" => $tokens,
Expand Down
7 changes: 2 additions & 5 deletions driver/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
namespace humhub\modules\fcmPush\driver;

use humhub\modules\fcmPush\components\SendReport;
use humhub\modules\fcmPush\models\ConfigureForm;
use humhub\modules\fcmPush\Module;
use humhub\modules\notification\models\Notification;
use humhub\modules\web\pwa\widgets\SiteIcon;
use Yii;
use yii\httpclient\Client;
use humhub\modules\fcmPush\models\ConfigureForm;

class Proxy extends Client implements DriverInterface
{
Expand All @@ -35,8 +33,7 @@ public function processCloudMessage(array $tokens, string $title, string $body,
'tokens' => $tokens,
'title' => $title,
'body' => $body,
'imageUrl' => $imageUrl,
'iconUrl' => SiteIcon::getUrl(180),
'iconUrl' => $imageUrl,
'url' => $url,
'notificationCount' => $notificationCount,
];
Expand Down
2 changes: 1 addition & 1 deletion services/MessagingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function processNotification(BaseNotification $baseNotification, User $us
Yii::$app->name,
$baseNotification->text(),
Url::to(['/notification/entry', 'id' => $baseNotification->record->id], true),
null,
SiteIcon::getUrl(180),
NotificationHumHub::findUnseen($user)->count(),
);
}
Expand Down

0 comments on commit 3c29d34

Please sign in to comment.