0

I'm in the process of enhancing a legacy app that receives various types of notifications, such as those from Firebase, third-party software, and even some that we create ourselves.

The data analytics team has asked me to track every click on these notifications, which got me thinking. I know about using PendingIntent actions, but our push notifications already link to an Activity with a PendingIntent. So I'm a bit unsure about how to also capture those clicks for tracking purposes.

I've come across suggestions about creating a Broadcast to capture actions, but unfortunately, that didn’t quite work out for me.

Is there a way to track clicks on any notifications that come into our app, whether they’re local or remote? The main goal is to add analytics to see if users are engaging with those notifications.

Another idea I had was to check within each Activity to see if it was opened from a push notification. However, I'm concerned about how practical that would be, especially since I'd like to avoid major code changes — going into every single Activity sounds like a lot of work! Plus, I'd need a way to identify if the Activity was opened from either a local notification created by us or from third-party sources, which I'm not entirely sure how to do.

Any thoughts or suggestions?

I have gone through this documentation.

2
  • "I'd need a way to identify if the Activity was opened from either a local notification created by us or from third-party sources" -- add extras onto the Intent that you wrap in a PendingIntent that indicate the source of the PendingIntent. "going into every single Activity sounds like a lot of work" -- it is almost 2025; having lots of activities is quite the code smell nowadays. Still, you can add your "look at the Intent for the notification extra" to a base activity class that the others extend. Commented Dec 29, 2024 at 13:13
  • Yes, it is definitely a code smell, but it is a source project of 12 years old, which we are improving slowing since we are small team, however improving is always second priority (unfortunately) Commented Dec 29, 2024 at 13:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.