Developers Software Development Tools Web

Send Push Messages to Firebase Cloud Messaging (Google) via PHP

Firebase Cloud Messaging (FCM) is a cross-platform (Android, IOS and Web) messaging solution by Google that lets you send messages at no cost… FCM was previously known as Google Cloud Messaging. (view the docs)

Achitecture overview – Firebase Cloud Messaging ( source: Google )

Using FCM you can notify a client app (Android or even an IOS application) that new email or other data is available to sync.
You can send notification messages to drive user re-engagement and retention (very important in Sales & Marketing).

Customer engagement is important. You’ll want to keep your customers informed about related products they might want to buy or if you offer a new service you want the to know. Push notifications are a quick and easy way to contact people directly.

Click here to go to the PHP script. Or if you prefer a solution writting in Go, capable sending push messages to both IOS and Android directly go down go GoRush.

For use-cases such as instant messaging (a message can transfer a payload of up to 4KB to a client app).

4KB is 1024 ~ 4096 letters. To give you an example scroll past the following text, assuming one byte per letter gives you this amount of text to send: click here to skip directly to the features

// 4096 characters

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In ac felis quis tortor malesuada pretium. Pellentesque auctor neque nec urna. Proin sapien ipsum, porta a, auctor quis, euismod ut, mi. Aenean viverra rhoncus pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non enim eleifend felis pretium feugiat. Vivamus quis mi. Phasellus a est. Phasellus magna. In hac habitasse platea dictumst. Curabitur at lacus ac velit ornare lobortis. Cura

That's 4096 characters of text.... a lot eh?


Firebase Cloud Messaging is the Google version of
Apple‘s counterpart Apple Push Notification Service. (Read more about APNs in a previous blogpost)

The standard features are what you’d expect of a messaging service:

  1. Send notification messages or data messages
    Send notification messages that are displayed to your user. Or send data messages and determine completely what happens in your application code.

  2. Target the audience you want!
    Distribute messages to your client app in any of 3 ways—to single devices, to groups of devices, or to devices subscribed to topics.

  3. Send messages from client apps back to your API
    Send acknowledgments, chats, and other messages from devices back to your server over FCM. (Google claims this is very energy efficient)

As an added benefit you can also use FCM to send messages to IOS devices. (You can’t send a message to Android devices from Apple’s service)

The real power of FCM? Analytics!

The real power of FCM is analytics and data.
You’ll get a GREAT dashboard and tons of options to review how you’re app is doing as an added benefit. It integrates perfectly with all the other tools of Google (like search console and analytics) so you can see how your app is performing (over time / per version)

It’s something you don’t get with Apple’s APNS out of the box.

PHP Script to send message

You can use the following script to send a message to Android device(s) registered via your App:


// API access key from Google API's Console
$apiKey = "FILL_IN_KEY_HERE";

// Device id's from Android devices.
$deviceIds = [

// Message payload
$payload = [
   'registration_ids' => $deviceIds,
   'notification' => [
       'title'   => ' Test Notification title',
       'body'    => 'Body of the notification...'

// headers
$headers = [
   "Authorization: key=$apiKey",
   "Content-Type: application/json"

$ch = curl_init();
// prod endpoint
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

// execute the request.
$result = curl_exec($ch);

// close the connection

GoRush: Push Notification Server that supports IOS and Android

  ________                              .__
 /  _____/   ____ _______  __ __  ______|  |__
/   \  ___  /  _ \\_  __ \|  |  \/  ___/|  |  \
\    \_\  \(  <_> )|  | \/|  |  /\___ \ |   Y  \
 \______  / \____/ |__|   |____//____  >|___|  /
        \/                           \/      \/

Usage: gorush [options]

As I mentioned in the previous post about a PHP script for push messages to mobile (IOS) devices, you can also use this great tool from appleboy written in Go. It’s called GoRush. You’ll get way way more performance, and features like an out-of-the-box Web API, Monitoring, Memory Usage, CLI, Retry/Resend and it also supports Push notification to Apple’s Push Notification Service.


Google LLC by Alphabet

Google LLC.

Don’t be evil they said… hah!

The creators of Chrome the anti-privacy browser.


Evil Chrome

Google “Evil” Chrome is an browser by Google. You can use it to browse the web. Because Google’s main source of income is running ads, they decided the best way to promote their vast array of services is by creating their own browser.

And since the launch in September 2008 the browser’s market share keeps increasing…

There is a problem with privacy in this browser.

It’s open source counterpart Chromium is a basis for many other browsers (Brave, Microsofts Edge)

Chrome also scans your computer (via the software reporter tool) for executables. if you want to prevent that follow this link: