I'm sending Push Notifications from a Cloud Function to my Android and iOS clients.
In Android I sent data notifications, and when the device gets a notification, I get to run arbitrary code. For example, I could log an event with Analytics of type "new_share_notification", with parameter "new_item_count": 5.
In iOS, as I understand it, I can't just receive a data notification and run arbitrary code as soon as it comes in; so I'm sending a non-data notification instead. How can I log an analytics event in that case? Some ideas:
- Have Cloud Functions log an analytics event with the same userId. But I don't think there's a nodejs api for Firebase Analytics. Am I right?
- Simultaneously send a data notification. As I understand it, when the app is opened, I can run arbitrary code if that happens.
- Put something in Firestore so the iOS client can see that there was a notification, and log it.
I'd prefer to log the existence of the notification right away, but I'm not sure if that's possible. I'd really like to be able to measure the connection between notifications and app use. Thoughts?
Thanks,
Bartholomew