-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually logging OPENED_PUSH not showing on klaviyo's dashboard #78
Comments
Thanks for this feedback, I'm going to take a look at adding better documentation and helper methods for custom display of notifications and logging an A quick answer though is that your manual |
Hey @evan-masseau |
@evan-masseau to give more context on how we are doing it, I did write more information: We already have Firebase setup and working in our project: class AppMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val notification = remoteMessage.notification
if (notification != null || remoteMessage.isKlaviyoNotification) {
showNotification(remoteMessage)
}
}
private fun showNotification(remoteMessage: RemoteMessage) {
if (!hasPostNotificationPermission) return
val isKlaviyoNotification = remoteMessage.isKlaviyoNotification
val title = if (isKlaviyoNotification) remoteMessage.title else remoteMessage.notification?.title
val body = if (isKlaviyoNotification) remoteMessage.body else remoteMessage.notification?.body
val deepLinkUri = if (isKlaviyoNotification) remoteMessage.deepLink else remoteMessage.data[DEEP_LINK_KEY]?.toUri()
// -- creating of the intent
val intent = Intent(this, AppActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// more custom payloads we use for our firebase notification
// then
// displaying custom notification with NotificationCompat
}
} Then on app startup in the AppActivity -> onCreate: override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Get custom payload from the intent
val isKlavioy = intent.getStringExtra(IS_KLAVIYO)
val deeplink = intent.extras?.getString(DEEP_LINK_KEY)
// ... other custom payloads
viewModel.trackNotificationClicked(notificationId, ..other payloads, isKlaviyo)
// Handle Deep link ( we do have our custom methods to handle deeplink ) The method that tracks the event is: trackNotificationClicked fun trackNotificationClicked(notificationId String?, ..other payloads, isKlaviyo: Boolean = false) {
analyticsManager.trackNotificationClicked(id, ..payloads, isKlaviyo)
if (isKlaviyo) {
// here we want to log Klaviyo's notification to see it on Klaviyo's dashboard
storage.getPushNotificationsToken()?.let { token ->
klaviyoManager.logOpenedPush(token, id.orEmpty())
}
}
fun logOpenedPush(pushToken: String, notificationId: String) {
val event = Event(EventType.OPENED_PUSH)
.setProperty(EventKey.PUSH_TOKEN, pushToken)
if (notificationId.isNotEmpty()) {
event.setProperty(EventKey.EVENT_ID, notificationId)
}
klaviyo.createEvent(event)
} We are not able to use Klaviyo's standard flow because we have Firebase Messaging also working in the project as I mentioned before |
Thanks! That is helpful context. Still working on a few updates that should help you out with a custom workflow like this. Now that I see the code I can definitely see why your event isn't getting logged as a valid opened push event. There is tracking data in the But here's an alternative you could try too. Instead of parsing our message out to display with your own logic, your firebase service could look like this: override fun onMessageReceived(remoteMessage: RemoteMessage) {
super.onMessageReceived(remoteMessage)
val notification = remoteMessage.notification
if (remoteMessage.isKlaviyoNotification) {
//Let Klaviyo SDK display notifications that originated from Klaviyo
KlaviyoNotification(remoteMessage).displayNotification(this)
} else if (notification != null) {
//Display notifications from elsewhere
showNotification(remoteMessage)
}
} and your intent handling like this override fun onCreate(savedInstanceState: Bundle?) {
//...
// handlePush ignores an intent that isn't from a Klaviyo push notification
Klaviyo.handlePush(intent)
//... handle your deep links etc. Klaviyo's display method attaches the deep link to the intent's data property, e.g:
intent?.data?.let {
//deep link logic...
navigateTo(it)
}
} We identify a Klaviyo push from the presence of tracking data, keyed //Detect if this intent has klaviyo tracking params
if (intent.getStringExtra("_k").isNotEmpty()) {
Klaviyo.handlePush(intent)
} Of course, if you want to stick to displaying the notification with custom logic, that is understandable too. I am going to look at writing a few utility functions to help
|
@evan-masseau If this Klaviyo.handlePush(intent) method doesn't handle deeplink, I can do call it in the onCreate. |
Hey again @iballan, I made this branch for you to try out:
I've tested this new method in a demo application to confirm that an opened push event is still created. Let us know how you go, hope this helps! |
@iballan Hey thanks again for working with us on this. Here is the syntax for using a specific branch from your gradle file:
You can find this syntax and explore what branches can be targeted on our repo's jitpack page: https://jitpack.io/#klaviyo/klaviyo-android-sdk |
Hey @evan-masseau, |
So glad to hear! Please reach out here if you ever have more questions, I'm going to close this issue then. We'll have a new public release soon that will include those extension methods. |
Hey this change is officially released now! You can update to v |
Description
We are trying to integrate Klaviyo's notification into project that already uses Firebase Messaging.
In
FirebaseMessagingService
's onMessageReceived we customize how the notification looks, so we are not able to useKlaviyoNotification
to display notification.So we extract the information from Klaviyo's notification and display.
// ... displaying notification with custom intent
Then when notification clicked, if it is Klaviyo's notification we are trying to track it like this:
Tracking method:
I couldn't find any document related to loggin EventType.OPENED_PUSH manually except in the code of EventKey:
So I added push_token as shown above in my tracking opened push
Checklist
main
branch of this package.Expected behavior
Actual behavior
Steps to reproduce
The Klaviyo Android SDK version information
1.1.0
Device Information
Emulator
Android Studio Version
Flamingo Patch 2 ( latest )
Android API Level
API Level 33
The text was updated successfully, but these errors were encountered: