繁体   English   中英

使用edujugon推送通知的Laravel Web推送通知

[英]Laravel Web Push notification using edujugon push-notification

我的项目有问题。 我将edujugon push-notification用于我的应用程序的推送通知,我成功创建了带有标题,正文的android,ios设备推送通知。 但是,当我将通知集成到Web设备中时,它不显示标题和正文,而是显示the site is upgrated in backend 我也想在我的网络通知中设置一个URL。 但是不知道如何。

这是我的代码

public static function sendPushNotification($devices, $pushData, $partner = false) {

    $android = $devices->where('type', 2)->pluck('token')->all();
    if (!empty($android)) {
        $push = new PushNotification('fcm');

        $push->setMessage(
            [
                'data' => $pushData,
            ]
        )
            ->setDevicesToken($android)
            ->send();
    }

    $ios = $devices->where('type', 1)->pluck('token')->all();

    if (!empty($ios)) {
        $push = new PushNotification('apn');

        $feedback = $push->setMessage(
                [
                    'aps' => [
                        'alert' => [
                            'title' => $pushData['title'],
                            'body' => $pushData['body'],
                        ],
                        'sound' => 'default',
                        'badge' => 1
                    ],
                    'data' => $pushData
                ]
        )->setDevicesToken($ios)->send()->getFeedback();
    }

    $web = $devices->where('type', 3)->pluck('token')->all();
    if (!empty($web)) {
        $push = new PushNotification('fcm');

        $push->setMessage($pushData)->setDevicesToken($web)->send();
    }
}

我的推送数据是

$pushData = [
    'title' => 'Test',
    'body' => 'Test',
];

请帮我解决这个问题

你应该写这个

if (!empty($web)) {
            $push = new PushNotification('fcm');

            $push->setMessage(
                [
                    'notification' => $pushData,
                ]
            )->setDevicesToken($web)->send();
        }

希望这可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM