pd Android FCM Push Notification

pd Android FCM Push Notification is a plugin through which you can send push notifications directly from your WordPress site to android devices via Firebase Cloud Messaging service. When a new blog is posted or existing blog is updated, a push notification sent to android device.

Demo App

Note: If you’re a beginner, please try to find out what is API and how to use it. Also you should be aware of how to integrate Google FCM in your android project.

Features Included

  • Can send push notification for each blog posted or updated (Please use Title, Excerpt & Featured image as data payload).
  • Even can send custom notifications to the registered IDs.
  • Devices are subscribed in category wise, so the notifications also be sent based on category (Need to select at least one category to send push notification to the registered device).
  • Big Picture image support is available by selecting Featured Image for each post (above android version 4.4).
  • Push notifications can be scheduled the same way a blog post is scheduled (Note: this will work only when a user visits your blog or site, as this schedule functionality depends on any page load)
  • A checkbox is available at the right side to choose whether to send push notification in post publish or update.

API’s

To register the device:

HTTP API (GET method)

http://yoursite.com/wp-json/pd/fcm/subscribe

Parameters

After passing these parameters, the output will be returned as, For eg.

  1. api_secret_key (Required) – Obtain it from the plugin dashboard
  2. user_email (Required)
  3. device_token (Required)
  4. subscribed (Required) – This would be the category in which the device is registered, if there is no category exists in WordPress it’ll be created automatically.
  5. device_name (Optional)
  6. os_version (Optional)

Returns

{
	"status": "ok",
	"message": "device token registered",
	"registered_id": 282
}

To unregister the device:

HTTP API (GET method)

http://yoursite.com/wp-json/pd/fcm/subscribe

Parameters

  1. unsubscribe = yes (Required) – Please set “yes” to unsubscribe the device
  2. device_token (Required)

Returns

After passing these parameters, the output will be returned as, For eg.

{
    "status": "ok",
    "message": "device token unregistered"
}

Push Notification:

When a custom notification is sent or a blog is posted, the data is sent to google FCM, so when a notification delivered from FCM, it’ll be in JSON format, like eg. below,

{
    "data": {
        "title": "Hey! you..",
        "message": "Great offers are waiting for you..",
        "image": null
    }
}

Note:

  1. JSON string "title" comes from Blog Post (or) Custom Post – title,
  2. JSON string "message" comes from Blog Post (or) Custom Post – excerpt,
  3. JSON string "image" comes from Blog Post (or) Custom Post – featured image,
  4. If a featured image is set in the blog post or custom notification, then the image JSON string "image" will have the image url with the size of 940×444.

Tips to android app developer:

Below is the eg. of Java code for android app, this way you can receive the data in JSON format from FCM and display the notification in your android app.

GitHub FCM Official Source code here
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getData().size() > 0) {
        Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
        try {
            JSONObject json = new JSONObject(remoteMessage.getData().toString());

            //getting the json data
            JSONObject data = json.getJSONObject("data");

            //parsing json data
            String title = data.getString("title");
            String message = data.getString("message");
            String imageUrl = data.getString("image");


        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
    }
}

Screenshots

WordPress backend
Android app

FAQ's

This plugin can send push notifications via Google FCM from your WordPress site to your Android App which should've functionality to receive the push notification message from Google FCM

This plugin is primarily intended for android mobile developers who do not want to develop their server-side back-end. Supporting push notifications is incredibly complicated. This plugin lets you focus on creating the apps, without the hassle.

Yes, its the Google FCM to send the push notifications. Visit to know more https://firebase.google.com/

Yes, there is a plugin available in Google Play Store and the link is given in our official documentation


Comments & Replies

Comments are closed for this post.

Wordpress
Themes & Plugins
...

pd Woo Tracking Order
Released On: September 22, 2019
Updated On: January 24, 2021

You can set the custom Woocommerce Order Status and can able to add a Tracking ID of your carrier service provider with a nice front end user interface of tracking system.

...

pd Android FCM Push Notification
Released On: June 17, 2018
Updated On: January 6, 2021

pd Android FCM Push Notification is a plugin through which you can send push notifications directly from your WordPress site to smart devices…