Silent Push

Silent push notifications allow background updates without interrupting the user. They are automatically handled within the SDK but can be customized for specific use cases.

Android SDK

Default Handling

Silent push notifications are automatically processed by the SDK in the onMessageReceived method.

Custom Handling

If you have other notification systems or multiple sources, use the dengage.showdengagenotification function to check whether Dengage should display the notification.

If dengage.showdengagenotification returns false, you can add custom logic to distinguish the notification’s source and decide whether or not to show it.

Example:

override fun onMessageReceived(remoteMessage: RemoteMessage) {
    super.onMessageReceived(remoteMessage)
    // Check if the notification should be shown by Dengage
    if (DengageUtils.showDengageNotification(remoteMessage.data)) {
        ContextHolder.resetContext(context = this)
        Dengage.onMessageReceived(remoteMessage.data)
    } else {
        // Extract the payload from the notification
        val dataPayload = remoteMessage.data
        // Check for the custom identifier "source"
        val customSource = dataPayload["source"]
        if (customSource != null && customSource == "your_custom_source") {
            // Handle notification from your custom source
            handleCustomSourceNotification(dataPayload)
        } else {
            // Handle other cases if needed
            Log.d("CustomNotification", "Notification is not from the custom source.")
        }
    }
}

iOS

On iOS, silent push notifications are automatically handled by the operating system. No extra configuration is needed.