【问题标题】:Laravel - How to change FCM default notification tuneLaravel - 如何更改 FCM 默认通知调整
【发布时间】:2021-08-31 01:50:17
【问题描述】:

这个问题之前被问过并且被忽略了,如果你有一个解决方案那么你的贡献是有价值的,如果我使用下面的代码,有没有办法改变 FCM 通知的默认声音,改变“声音“=>”到达“配乐路径不起作用? 谢谢你

public function toFcm($notifiable) {
    $message = new FcmMessage();
    $notification = [
        'body' => trans('lang.notification_your_order', ['parcel_id' => $this->parcel->id, 'order_status' => $this->parcel->parcelStatus->status]),
        'image' => Config::get('app.url').'/uploads/parcel.png',
        'icon' => Config::get('app.url').'/uploads/parcel.png',
        "title" => "Order Updated",   
        "content_available" => true,
        "priority" => "high",
        "sound"=>"arrive",
        'id' => 'orders',
    ];
    $data = [
        'click_action' => "FLUTTER_NOTIFICATION_CLICK",
        'id' => 'orders',
        'status' => 'done',
        'message' => $notification,
    ];
    $message->content($notification)->data($data)->priority(FcmMessage::PRIORITY_HIGH);
    return $message;
}

【问题讨论】:

    标签: php laravel firebase-cloud-messaging


    【解决方案1】:

    确保声音名称与安装在 res/raw 文件夹中的声音名称匹配,然后确保您的请求格式正确

    示例:“文件名.mp3”

    {
      "token": "client_notification_token", <- or topic
      "notification": {
        "title": "Push notification title",
        "body": "Push body",
        "sound": "filename", <-- points to src/res/raw/filename.mp3
      }
      ...
    }
    

    来源:https://medium.flatstack.com/migrate-to-api-26-push-notifications-with-custom-sound-vibration-light-14846ebc9e96

    【讨论】:

    • 所以这也需要在应用程序上工作?我没有处理应用程序的经验,但我可以使用 Flutter 工作,而且我的应用程序是由 Flutter 的初学者开发人员完成的
    • 如果你不知道你不知道要播放什么声音,FCM不会每次都发送声音文件,只有要播放的名称。
    • 那么有什么办法可以做到这一点吗?我已经在 android->app->src->main->res->raw->sound.mp3 中添加了 mp3 文件,但是当我按下 fcm 并放置名称文件时,只播放默认声音
    猜你喜欢
    • 2022-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-28
    • 2020-01-18
    • 1970-01-01
    • 2023-03-17
    相关资源
    最近更新 更多