簡體   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