klaviyo / klaviyo-react-native-sdk

MIT License
4 stars 3 forks source link

Integrating the tracking of open events on the Android side of the example. #144

Closed youcefswoo closed 2 months ago

youcefswoo commented 5 months ago

Checklist

Description

The documentation for integrating the tracking of open events is not clear, as native Kotlin projects and React Native have different architectures.

Proposed Solution

I'm writing to ask for further explanation in the documentation, along with a demonstration on the Android side of the example.

Alternatives Considered

No response

Additional Context

No response

evan-masseau commented 5 months ago

Hi, the short answer is that on both platforms we require you to write native code to handle push opens because notification opens are handled very differently by platform. That is why we link to our native SDKs' documentation. For Android that will mean handling an intent from the main activity. I will work on an example app update for the android side to demonstrate, but wanted to answer you sooner than later.

youcefswoo commented 5 months ago

@evan-masseau I implemented it as shown in the screenshot, but when I tap the notification, the app crashes on Android.

image
evan-masseau commented 5 months ago

@youcefswoo Hmm which version of the RN SDK? And I am guessing you're initializing from typescript code?

evan-masseau commented 5 months ago

Can you see error output in logcat? This is probably a timing issue of invoking Klaviyo prior to initializing, going to have to think about how we can work around that.

youcefswoo commented 5 months ago

@evan-masseau yes, I'm initializing the SDK on the React Native side. Do you still need the logs? Klaviyo SDK : 3.0.1 RN version : 0.73.3

evan-masseau commented 5 months ago

@youcefswoo I can probably get started with this much detail. Thank you for all your contributions, I'll update as soon as I can!

youcefswoo commented 4 months ago

@evan-masseau I switched the initialization of the SDK on the native side to make the tap on notifications work. So, it's not a bug, but I believe it would be beneficial for the SDK to offer a way to perform tracking on the React Native side as well.

github-actions[bot] commented 4 months ago

This issue is stale due to inactivity. Please let us know if you are still encountering issues, otherwise this issue will automatically close in 10 days.

evan-masseau commented 4 months ago

@evan-masseau I switched the initialization of the SDK on the native side to make the tap on notifications work. So, it's not a bug, but I believe it would be beneficial for the SDK to offer a way to perform tracking on the React Native side as well.

Fully agree, my first goal will be to enable the open tracking on Android without requiring you to also move your initialization logic. Tracking opens for both platforms from react native code is a harder lift, so I'm going to consider that a separate goal.

evan-masseau commented 2 months ago

With our latest release, 0.4.2, the timing issue related to tracking an opened push event and initializing Klaviyo SDK from react native code should now be resolved. We now hold that event in memory until Klaviyo gets initialized to work around this platform/timing limitation. Thanks for bearing with us, we'll continue to consider options for tracking this event from react native code, however as I mentioned before doing that in a cross-platform way is going to be tricky.

oorestisime commented 1 month ago

@evan-masseau I switched the initialization of the SDK on the native side to make the tap on notifications work. So, it's not a bug, but I believe it would be beneficial for the SDK to offer a way to perform tracking on the React Native side as well.

Fully agree, my first goal will be to enable the open tracking on Android without requiring you to also move your initialization logic. Tracking opens for both platforms from react native code is a harder lift, so I'm going to consider that a separate goal.

hi @evan-masseau , any news regarding offering open tracking capabilities on RN? I am currently working on an expo app and doing this from a managed expo isnt the most trivial i would say.