Skip to content

Commit

Permalink
fixing push messaging in android native
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-aman committed Sep 24, 2024
1 parent e50e166 commit 7ccec97
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.facebook.react.bridge.*
import com.facebook.react.modules.core.PermissionAwareActivity
import com.facebook.react.modules.core.PermissionListener
import io.customer.messagingpush.CustomerIOFirebaseMessagingService
import io.customer.messagingpush.MessagingPushModuleConfig
import io.customer.messagingpush.ModuleMessagingPushFCM
import io.customer.messagingpush.di.pushTrackingUtil
import io.customer.reactnative.sdk.extension.takeIfNotBlank
import io.customer.reactnative.sdk.extension.toFCMRemoteMessage
Expand All @@ -32,6 +34,10 @@ class RNCIOPushMessaging(
*/
private var notificationRequestPromise: Promise? = null

private val SDKComponent.pushModuleConfig: MessagingPushModuleConfig
get() = newInstance {
modules["MessagingPushFCM"]?.moduleConfig as? MessagingPushModuleConfig ?: MessagingPushModuleConfig.default()
}
init {
reactContext.addActivityEventListener(this)
}
Expand Down Expand Up @@ -176,7 +182,7 @@ class RNCIOPushMessaging(
) {
// Nothing required here
}

/**
* If the app is in background and simple push is received, then FCM notification doesn't
* start new intent apparently because of `singleTask` launchMode being used by React Native
Expand All @@ -189,20 +195,15 @@ class RNCIOPushMessaging(
override fun onNewIntent(intent: Intent?) {
val intentArguments = intent?.extras ?: return
//TODO: Implement pushMessaging later
/*
kotlin.runCatching {
val sdkInstance = CustomerIO.instance()
val pushMessagingModuleConfig = sdkInstance.pushMessaging().moduleConfig
if (pushMessagingModuleConfig.autoTrackPushEvents) {
if (SDKComponent.pushModuleConfig.autoTrackPushEvents) {
SDKComponent.pushTrackingUtil
.parseLaunchedActivityForTracking(intentArguments)
}
}.onFailure { ex ->
logger.error("Unable to parse push notification intent, reason: ${ex.message}")
}
*/

}

override fun getName(): String = "CioRctPushMessaging"
Expand All @@ -223,4 +224,4 @@ class RNCIOPushMessaging(
private const val BUILD_VERSION_CODE_TIRAMISU = 33
private const val POST_NOTIFICATIONS_PERMISSION_REQUEST = 24676
}
}
}

0 comments on commit 7ccec97

Please sign in to comment.