Trying to Understand Push Notifications Hybrid

I try to make a simple script to send a push notification to a device. Somehow, I know people have to “accept” notifications in the browser, but I also want it to be possible to send the push notification directly to their phone, and not only “in the browser”.

Can any help me with the following code, and tell me, how I can receive that information to move forward with my idea?

<!-- Install Firebase ?? -->

<script type="module">
  // Import the functions you need from the SDKs you need
  import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-app.js";
  import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.22.1/firebase-analytics.js";
  // TODO: Add SDKs for Firebase products that you want to use
  // https://firebase.google.com/docs/web/setup#available-libraries

  // Your web app's Firebase configuration
  // For Firebase JS SDK v7.20.0 and later, measurementId is optional
  const firebaseConfig = {
    apiKey: "XXXXXXX",
    authDomain: "remindly-30fb7.firebaseapp.com",
    projectId: "remindly-30fb7",
    storageBucket: "remindly-30fb7.appspot.com",
    messagingSenderId: "xxxxxxxxx",
    appId: "1:632795751581:web:0075b5505db3872df9e074",
    measurementId: "G-GWQCRDQDHV"
  };

  // Initialize Firebase
  const app = initializeApp(firebaseConfig);
  const analytics = getAnalytics(app);

  console.log(app);
  console.log(analytics);
</script>


<?php
error_reporting(E_ALL);

$API_ACCESS_KEY = "AXXXX"; //this one i got
$passphrase = "?????=??????????"; //Dont know what to put here
$channelName = "?????=??????????"; //Dont know what to put here

/** Push notification data **/
$push_title = "Jesper has birthday in 7 days!!";
$push_text =
    "your co-worker has birthday in 7 days - find the perfect present here!";



function android($reg_id)
{
    global $API_ACCESS_KEY;
    global $push_text;
    global $push_title;

    $url = "https://android.googleapis.com/gcm/send";
    $message = [
        "title" => $push_title,
        "message" => $push_text,
        "subtitle" => "",
        "tickerText" => "",
        "msgcnt" => 1,
        "vibrate" => 1,
    ];

    $headers = [
        "Authorization: key=" . $API_ACCESS_KEY,
        "Content-Type: application/json",
    ];

    $fields = [
        "registration_ids" => [$reg_id],
        "data" => $message,
    ];

    return useCurl($url, $headers, json_encode($fields));
}

function WP($uri)
{
    global $push_text;
    global $push_title;

    $delay = 2;
    $msg =
        "<?xml version="1.0" encoding="utf-8"?>" .
        "<wp:Notification xmlns:wp="WPNotification">" .
        "<wp:Toast>" .
        "<wp:Text1>" .
        htmlspecialchars($push_title) .
        "</wp:Text1>" .
        "<wp:Text2>" .
        htmlspecialchars($push_text) .
        "</wp:Text2>" .
        "</wp:Toast>" .
        "</wp:Notification>";

    $sendedheaders = [
        "Content-Type: text/xml",
        "Accept: application/*",
        "X-WindowsPhone-Target: toast",
        "X-NotificationClass: " . $delay,
    ];

    $response = useCurl($uri, $sendedheaders, $msg);

    $result = [];
    foreach (explode("n", $response) as $line) {
        $tab = explode(":", $line, 2);
        if (count($tab) == 2) {
            $result[$tab[0]] = trim($tab[1]);
        }
    }

    return $result;
}

function iOS($devicetoken)
{
    global $passphrase;

    $deviceToken = $devicetoken;

    $ctx = stream_context_create();
    // ck.pem is your certificate file
    stream_context_set_option($ctx, "ssl", "local_cert", "ck.pem");
    stream_context_set_option($ctx, "ssl", "passphrase", $passphrase);

    // Open a connection to the APNS server
    $fp = stream_socket_client(
        "ssl://gateway.sandbox.push.apple.com:2195",
        $err,
        $errstr,
        60,
        STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT,
        $ctx
    );

    if (!$fp) {
        exit("Failed to connect: $err $errstr" . PHP_EOL);
    }

    // Create the payload body
    $body["aps"] = [
        "alert" => [
            "title" => $push_title,
            "body" => $push_text,
        ],
        "sound" => "default",
    ];

    // Encode the payload as JSON
    $payload = json_encode($body);

    // Build the binary notification
    $msg =
        chr(0) .
        pack("n", 32) .
        pack("H*", $deviceToken) .
        pack("n", strlen($payload)) .
        $payload;

    // Send it to the server
    $result = fwrite($fp, $msg, strlen($msg));

    // Close the connection to the server
    fclose($fp);

    if (!$result) {
        return "Message not delivered" . PHP_EOL;
    } else {
        return "Message successfully delivered" . PHP_EOL;
    }
}

function useCurl($url, $headers, $fields = null)
{
    // Open connection
    $ch = curl_init();
    if ($url) {
        // Set the url, number of POST vars, POST data
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        // Disabling SSL Certificate support temporarily
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        if ($fields) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        }

        // Execute post
        $result = curl_exec($ch);
        if ($result === false) {
            die("Curl failed: " . curl_error($ch));
        }

        // Close connection
        curl_close($ch);

        return $result;
    }
}

//Send notification to android device? ((Where to find 'reg_id' id?? ))
android("reg_id???????? where to find?");

//Send notification to iOS device? (where to find 'devicetoken' ?? ))
iOS("devicetoken??? where to find??");

//Send notification to Windows device? (Where to find '$uri'? parameters? What is that?)
WP("uri, where to find ???");

?>

Can any guide me through the process to get this working? Where should i apply, etc?