Android启动Firebase通知无效

Android启动Firebase通知无效,android,flutter,firebase-cloud-messaging,Android,Flutter,Firebase Cloud Messaging,我已经被困在这个看似简单的问题上4天了。我想让我在安卓系统中的通知像在iOS中一样以横幅的形式出现,我被告知这些通知被称为提示通知。在查看了很多帖子后,我觉得我只需要将优先级设置为high并启用sound 但是,我无法从FCM控制台执行任何操作,也无法从我正在使用Kreit的laravel后端执行任何操作 当我首先使用firebase验证通知时,通知正在工作并到达设备。我收到通知,但它们是离散的,声音确实发生了,但没有横幅 我读过一些帖子,上面说你需要修改清单文件,并在android方面做一些事

我已经被困在这个看似简单的问题上4天了。我想让我在安卓系统中的通知像在iOS中一样以横幅的形式出现,我被告知这些通知被称为提示通知。在查看了很多帖子后,我觉得我只需要将优先级设置为high并启用sound

但是,我无法从FCM控制台执行任何操作,也无法从我正在使用Kreit的laravel后端执行任何操作

当我首先使用firebase验证通知时,通知正在工作并到达设备。我收到通知,但它们是离散的,声音确实发生了,但没有横幅

我读过一些帖子,上面说你需要修改清单文件,并在android方面做一些事情。我完全迷路了

这是我在laravel上的全部有效载荷,工作正常,只是没有抬头


        $deviceToken = 'chcC_kgZHrI0VpqpdPClE8XGJzwWV';
        // $name = 'Notification name'; //FIX_THIS_SOON figure this out soon
        $topic = 'Notification topic'; //FIX_THIS_SOON figure this out soon
        $condition = 'Notification condition'; //FIX_THIS_SOON figure this out soon
        $notificationTitle = 'Package is being delivered';
        // $notificationBody = 'Your order 9847GH8409 is on it\'s way to you.'; //version 1
        // $notificationBody = 'Your order 9847GH8419 is on it\'s way to you.'; //version 2
        $notificationBody = 'Your order 9847GH8429 is on its way to you.'; //version 3
        $notificationIcon = 'http://lorempixel.com/400/200/'; //
        $notificationImageUrl = 'http://lorempixel.com/400/200/';
        $notificationPriority = 'high';
        $apnsPayloadBadge = 42; //FIX_THIS_SOON
        $analyticsLabel = 'some-analytics-label'; //FIX_THIS_SOON

        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification
        $notificationPayload = [
            'title' => $notificationTitle,
            'body' => $notificationBody,
            //'image' => $notificationImageUrl,
        ];

        //payload needs to be configured from the parent function as an array, don't pass individual elements
        $data = [
            'click_action' => 'FLUTTER_NOTIFICATION_CLICK',
            'action' => 'new_notification',
            'priority' => 'high', //does this need to be here?
            'sound' => 'default', //does this need to be here?
            'notification_id' => '888888888',
            'notification_uid' => '1111-2222-3333-4444',
            'notification_foreignUID' => '5555-6666-7777-8888',
            'notification_foreignUID_type' => 'user',
            'notification_title' => $notificationTitle,
            'notification_message' => $notificationBody,
            'notification_asset_type' => 'image',
            'notification_image' => 'http://127cf52a.ngrok.io/storage/images_products/860a6ac4-bd66-4c3b-b07f-450f7cdcc007_2020-01-20_15-15-21_0001.jpg',
            'notification_icon' => null,
            'notification_account_type' => 'client',
            'notification_read_status' => '0',
            'notification_status' => 'active',
            'notification_created_at' => '2020-03-29 02:09:00',
            'notification_updated_at' => '2020-03-29 02:09:00',
        ];

        $androidTtl = '3600s';

        $androidCollapseKey = '';

        $androidRestrictedPackageName = '';

        $androidNotificationPayload = [
            'title' => $notificationTitle,
            'body' => $notificationBody,
            // 'icon' => 'string',
            // 'color' => 'string',
            'sound' => 'default',
            // 'tag' => 'string',
            'click_action' => 'FLUTTER_NOTIFICATION_CLICK',
            // 'body_loc_key' => 'string',
            /* 'body_loc_args' => [
                'string'
            ], */
            // 'title_loc_key' => 'string',
            /* 'title_loc_args' => [
                'string'
            ], */
            'channel_id' => 'Notifications',
            // 'ticker' => 'string',
            'sticky' => false, //When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to true, the notification persists even when the user clicks it.
            // 'event_time' => 'string',
            'local_only' => true,
            'notification_priority' => 'priority_high', //also priority_max
            'default_sound' => true,
            'default_vibrate_timings' => true,
            'default_light_settings' => true,
            /* 'vibrate_timings' => [
                'string'
            ], */
            // 'visibility' => 'private',
            // 'notification_count' => integer,
            /* 'light_settings' => {
                "color" => {
                    object (Color)
                },
                "light_on_duration": string,
                "light_off_duration": string
            }, */ //i can't get to write the object properly
            // 'image' => $notificationImageUrl
        ];

        $androidFcmOptions = [
            'analytics_label' => $analyticsLabel //optional
        ];

        $webPushHeaders = [
            'Urgency' => 'high',
        ];

        $webPushFcmOptions = [
            // 'link' => '',
            'analytics_label' => $analyticsLabel //optional
        ];

        $apnsHeaders = [
            'apns-priority' => '10',
        ];

        $apnsPayload = [
            'aps' => [
                'alert' => [
                    'title' => $notificationTitle,
                    'body' => $notificationBody,
                ],
                'badge' => $apnsPayloadBadge,
            ],
        ];

        $apnsFcmOptions = [
            // 'image' => '',
            'analytics_label' => $analyticsLabel //optional
        ];

        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#androidconfig
        $androidSettings = [
            'ttl' => $androidTtl,
            'priority' => $notificationPriority,
            // 'collapse_key' => $androidCollapseKey,
            // 'restricted_package_name' => $androidRestrictedPackageName,
            'notification' => $androidNotificationPayload,
            'data' => $data,
            'fcm_options' => $androidFcmOptions,
        ];

        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#apnsconfig
        $apnsSettings = [
            'headers' => $apnsHeaders,
            'payload' => $apnsPayload,
            'fcm_options' => $apnsFcmOptions,
        ];

        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushconfig
        $webpushSettings = [
            'headers' => $webPushHeaders,
            'notification' => $androidNotificationPayload,
            'data' => $data,
            'fcm_options' => $webPushFcmOptions,
        ];

        //hide fcm_options if you are leaving it empty
        // https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#fcmoptions
        $fcmOptions = [
            'analytics_label' => $analyticsLabel //optional
        ];

        //DELETE_SOON
        Log::channel('merlin_debug')->info('option 3 222');

        $message = new RawMessageFromArray([
            'token' => $deviceToken,
            // 'name' => $name,
            // 'topic' => $topic,
            // 'condition' => $condition,
            'notification' => $notificationPayload,
            'data' => $data,
            'android' => $androidSettings,
            'apns' => $apnsSettings,
            'webpush' => $webpushSettings,
            'fcm_options' => $fcmOptions
        ]);

        $messaging = app('firebase.messaging');

        $messaging->send($message);