Enhancing Farmer Connectivity: Fasal App’s Journey with Push Notifications

Vedant Sasane
Fasal Engineering
Published in
3 min readFeb 16, 2024

At Fasal, staying connected with the farmers and providing real-time updates is crucial. Push Notifications play an important role in delivering essential information to farmers, like rainfall forecasts, personalized irrigation advisories, crop growth stage updates etc.

In this blog we will delve into the overall architecture of how we send push notifications to the farmers, and how we transitioned from deprecated raix:push Meteor package to a more robust solution.

The Need for Migration

The raix:push plugin, Fasal’s initial push notification solution, served its purpose well, However with its deprecation and lack of crucial features , including analytics we decided to seek a more dependable solution.

We explored various Notification service providers like Onesignal, Clevertab etc.. Still, we decided to go with the native FCM approach by using an open source cordova plugin for having more control over our setup.

Also, check out our push implementation specifics in our earlier days,

Key points on which we improved upon migration

1 . Analytics and Insights :

Firebase Cloud Messaging Provides detailed analytics on notification engagement.

FCM statistics

2. Rich Push Notifications

We can now send the Notification with images and action buttons

Rich Push Notifications with images & action buttons

3. Up to Date with the latest Firebase Admin SDK

For sending the push notifications to users we were using Firebase Legacy HTTP Protocol API but Firebase has announced its plan to terminate the usage of legacy Firebase Cloud Messaging (FCM) APIs effective June 20, 2024. So we have fully migrated to Firebase Admin SDK to send the notifications. Official documentation link

New Architecture

The flow of sending the notifications looks like this

  1. Event Triggering via AWS SQS
    When a specific event occurs in one of the services, the service packages the event details and triggers an AWS SQS queue by sending message on it. This message includes the necessary information for the notification .
  2. Worker Processing for Token Retrieval
    A dedicated worker continuously polls the SQS queue for new messages. Upon receiving a message, the worker processes it by first identifying the users affected by the event.
    After that, it retrieves their device tokens, which are necessary for sending push notifications through FCM. This step involves querying a database where user tokens are stored, mapping the event to the users’ device identifiers
  3. Notification Dispatch via Firebase Cloud Messaging (FCM)
    With the device tokens retrieved, the worker constructs the push notification payload according to the event’s context (e.g., message content, data payload for app interaction). It then sends this payload to FCM, specifying the retrieved tokens as the destination. Firebase Cloud Messaging handles the delivery of these notifications to the user's devices

Finally..

The migration to Firebase Cloud Messaging (FCM) has significantly improved Fasal’s ability to engage with farmers by providing real-time updates and essential information like rainfall forecasts, irrigation advisories, and crop growth stages. With FCM’s detailed analytics, Fasal now has a deeper understanding of notification engagement, allowing for more informed decisions and strategies to further increase user interaction and satisfaction.

--

--