Skip to content

Commit

Permalink
feat: added option to customize push notification from app
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Aug 23, 2022
1 parent 2f20ac3 commit 68010f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Expand Up @@ -162,6 +162,11 @@ internal class CustomerIOPushNotificationHandler(private val remoteMessage: Remo
title = title,
body = body
)

moduleConfig.notificationCallback?.onNotificationComposed(
payload = payload,
builder = notificationBuilder
)
createIntentFromLink(
context,
requestCode,
Expand Down
@@ -1,6 +1,7 @@
package io.customer.messagingpush.data.communication

import android.content.Context
import androidx.core.app.NotificationCompat
import androidx.core.app.TaskStackBuilder
import io.customer.messagingpush.data.model.CustomerIOParsedPushPayload

Expand All @@ -20,5 +21,24 @@ interface CustomerIOPushNotificationCallback {
fun createTaskStackFromPayload(
context: Context,
payload: CustomerIOParsedPushPayload
): TaskStackBuilder?
): TaskStackBuilder? = null

/**
* Called when all attributes for the notification has been set by the SDK
* and the notification is about to be pushed to system tray.
* <p/>
* Please note that overriding the pending intent for notification is not
* allowed as it can affect tracking and other metrics. Please override
* [createTaskStackFromPayload] instead to launch desired intent(s).
* <p/>
* @see [createTaskStackFromPayload] to override click action
*
* @param payload data received for the notification
* @param builder notification builder that is being used to build
* notification attributes
*/
fun onNotificationComposed(
payload: CustomerIOParsedPushPayload,
builder: NotificationCompat.Builder
) = Unit
}
@@ -1,11 +1,8 @@
package io.customer.messagingpush

import android.content.Context
import androidx.core.app.TaskStackBuilder
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.customer.commontest.BaseTest
import io.customer.messagingpush.data.communication.CustomerIOPushNotificationCallback
import io.customer.messagingpush.data.model.CustomerIOParsedPushPayload
import io.customer.messagingpush.di.moduleConfig
import io.customer.sdk.CustomerIOConfig
import io.customer.sdk.CustomerIOInstance
Expand Down Expand Up @@ -78,14 +75,7 @@ internal class ModuleMessagingConfigTest : BaseTest() {
val module = ModuleMessagingPushFCM(
moduleConfig = MessagingPushModuleConfig.Builder().apply {
setAutoTrackPushEvents(false)
setNotificationCallback(
object : CustomerIOPushNotificationCallback {
override fun createTaskStackFromPayload(
context: Context,
payload: CustomerIOParsedPushPayload
): TaskStackBuilder? = null
}
)
setNotificationCallback(object : CustomerIOPushNotificationCallback {})
setRedirectDeepLinksToOtherApps(false)
}.build(),
overrideCustomerIO = customerIOMock,
Expand Down

0 comments on commit 68010f8

Please sign in to comment.