簡體   English   中英

如何使通知與聲音一起工作這不適用於 android 中的聲音甚至默認通知聲音

[英]How to make notification work with sound this not working with sound or even default notification sound in android

如何使通知在此 Php laravel 項目中與聲音一起工作 這在 android 中無法使用聲音甚至默認通知聲音

public function toFcm($notifiable)
{
    $message = new FcmMessage();
    $notification = [
        'title'        => "New Order #".$this->order->id." to ".$this->order->foodOrders[0]->food->restaurant->name,
        'body'         => $this->order->user->name,
        'icon'         => $this->order->foodOrders[0]->food->restaurant->getFirstMediaUrl('image', 'thumb'),
        'click_action' => "FLUTTER_NOTIFICATION_CLICK",
        'id' => '1',
        'status' => 'done',
    ];
    $message->content($notification)->data($notification)->priority(FcmMessage::PRIORITY_HIGH);

    return $message;
}

嘗試使用 setAndroid 方法:

 $message->content($notification)->data($notification)->priority(FcmMessage::PRIORITY_HIGH) ->setAndroid(
            AndroidConfig::create()
                ->setNotification(AndroidNotification::create()
                    ->setNotificationPriority(NotificationPriority::PRIORITY_DEFAULT())
                    ->setDefaultSound(true)
                ));

方法setDefaultSound(true)告訴 android 運行默認聲音。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM