How to Send Silent Push Notifications Using PHP And Firebase

Silent Push Notifications Using PHP And Firebase

This article is useful for PHP developers who want to send silent push notifications by using PHP with FCM (Firebase Cloud Messaging).

What Is Silent Push Notifications?

If you send a silent push notification, call it a background notification that does not trigger any sound or alert. It wakes up your apps in the background and allows you to perform any action/operations. Generally, silent push notifications are used in background content updates.

If you are unable to send silent push notifications to iOS using FCM, This article is useful for you. In this article, let’s look into how you can send a silent push notification to your iOS device using PHP with firebase cloud messaging.

If you want to send a simple push notification to Android/IOS, Check out our article Send Push Notification to Android Using PHP And Firebase.

How to Send a Silent Push Notification Using PHP?

Prerequisite:

1) Authorization key (Server Key)
2) Device Token
You can get the device token at the time of registering by the android users using API.
3) You need to add “Background Modes” capabilities in Xcode in order for your app to be able to receive a silent push notification. See the below image.

Lets Create PHP Files

  1. Create a file named fcm.php and past below push notification code. Here we define the Firebase Server API Key to send a request to firebase.

Be sure to replace the Your Firebase Server API Key Here with a proper one from the Google API’s Console page.

2. Finally, create an index.php and paste the below code.

Before testing please replace Your Device Token with your real device token.

Today, We learn How to Send Silent Push Notifications Using PHP And Firebase.
Hope it helped you with an easy way to send silent push notifications to android and IOS using PHP. Please let us know in the comment section if you have any concerns.