Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Alphal1234's avatar

Push Notification doesn't work in iOS with Firebase,

Trying to figure out why push notification doesn't work in iOS. Here is the code of push notification.It works fine in Android. Can you please help me ?

public function notification($token, $load, $type = NULL) { $url = 'https://fcm.googleapis.com/fcm/send';

            $fields = array(
                'registration_ids' => $token,
                'data' => $load
            );
            // 'notification' => $load
            $headers = array(
                'Authorization:key=********************',
                'Content-Type: application/json'
            );


            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
            // echo json_encode($fields);
            $result = curl_exec($ch);
            echo curl_error($ch);
            if ($result === FALSE) {
                die('Curl failed: ' . curl_error($ch));
            }
            curl_close($ch);
            return $result;


        }
0 likes
2 replies

Please or to participate in this conversation.