Silent / Background InApp Notifications

These notifications lack a visible user interface element but come with valuable data payloads. To effectively use this feature, you must create a notification template in the Fyno application, specifying the template type as "silent." Additionally, developers must integrate the onMessageReceived event handler into the In-App SDK configuration to capture these silent notifications.

This documentation provides a comprehensive guide on creating a silent notification template in Fyno and capturing these notifications in your application.

Creating a Silent Notification Template in Fyno

To create a silent notification template in Fyno, follow these steps:

  1. Accessing Fyno Application: Access your Fyno account and navigate to the Templates section.
  2. Template Creation:
    • Click the "Create Template" button or edit an existing template.
    • Set the template type to "Silent." This indicates that this notification template will be used for sending silent notifications.
    • Define the data payload.
    • You can leave placeholders for content that can be dynamically filled by your application.
  3. Final Step: Save and promote your template and It's ready to use

Capturing silent notification in your application

To capture the incoming silent notification in your application, You need to pass the event handlers(onMessageReceived and onMessageClicked) to the In-App SDK

  1. SDK Integration:
    Ensure you have integrated the Fyno's In-App SDK into your application by following the Integration Guide.

  2. Configure Event Handlers
    While configuring the SDK, include onMessageReceived and onMessageClicked event handler props and pass your custom message handler methods.
    Define the message handler functions in your application to handle incoming silent notifications and to handle notification click/deleted events.

    In your messageHandler function, access the silent notification data payload and perform actions based on the received data. For example

    const onMessageHandler = (incoming) => {
      // Handle the silent notification data payload here
      const data = incoming.notification.additional_data
      // Perform actions based on the data received
    }
    
    <FynoInappCenter {...config} onMessageReceived={onMessageHandler} onMessageClicked={onClickHandler}/>
    

📘

Note

Ensure you are using @fyno/inapp-react library - v1.0.15 or later.

Use Case

Consider a scenario where users initiate payments in your application, and you want to send silent notifications to update payment information in real-time without disrupting users with visible notifications. Follow these steps to achieve this

const messageHandler = (notification) => {
  // Handle the silent notification data payload
  const data = notification.notification_content.additional_data

  // Update the state information in your app
  updatePaymentInformation(data)
}

<FynoInappCenter {...config} onMessageReceived={messageHandler} />

Conclusion

By creating a silent notification template in Fyno and configuring the In-App SDK with the onMessageReceived event handler, developers can easily send and capture silent notifications in their applications. This feature enables non-intrusive updates and real-time data synchronisation while delivering a seamless user experience.