IOS Push Notification Send Example

  • 03-05-2022
  • 867
  • PHP
  • Haresh Chauhan

In this post you will learn how to send apple notification or IOS notification using apn voip token in php.

Here below is the working example in how to send IOS notification in php so please follow the one by one example line and make it success in your php application.

Firebase Notification Send PHP Example

Before you start you have to generate p8 file from your server and after generate bundleId from it, follow the below example.


   $authKey = 'AuthKey_FILE.p8';
   $teamId = </YOUR-TEAM-ID>;
   $tokenId = </YOUR-TOKEN-ID>;
   $production = false; // true to production server
   $notification_payload = []; // your notification data or payload like title body

   $token_key = file_get_contents($authKey);

   $jwt_header = [
       'alg' => 'ES256', 
       'kid' => $tokenId

   $jwt_payload = [
       'iss' => $teamId, 
       'iat' => time()

   $raw_token_data = b64($jwt_header, true).".".b64($jwt_payload, true);

   $signature = '';

   openssl_sign($raw_token_data, $signature, $token_key, 'SHA256');

   $jwt = $raw_token_data.".".b64($signature);

   $request_body = json_encode($notification_payload);
   $endpoint = $production ? '': '';
   $url = "$endpoint/$token";

   $ch = curl_init($url);

   curl_setopt_array($ch, [
       CURLOPT_POSTFIELDS => $request_body,
           "content-type: application/json",
           "authorization: bearer $jwt",
           "apns-topic: $bundleId"

   $response = curl_exec($ch);
   $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
   $err = curl_error($ch);

   echo 'IOS notification send successfully.'

Thank you for read our post.

We always thanks to you for reading our blogs.


Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us


Haresh Chauhan


We Are Also Recommending You :