Skip to content
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

feat(messaging): add support for setDeliveryMetricsExportToBigQuery #6529

Conversation

pavan168
Copy link
Contributor

Description

We have had very specific requirements to send out push notifications using FCM and have implemented an in-house solution using the Firebase Admin SDK. However, we don't get access to the message delivery information in the Firebase Console anymore and want to use BigQuery to analyse this information.

Reading through the documentation we found that the message delivery data export needs to be enabled on the device (after asking for consent of course) and both ios and android native methods are not exposed as per the RNFirebase documentation.

With this PR, we can use setDeliveryMetricsExportToBigQuery method to pass down the status (a boolean value) and have used deliveryMetricsExportToBigQueryEnabled() method that exist already on android to return the updated status whilst iOS does not have a similar method, isDeliveryMetricsExportToBigQueryEnabled is introduced that holds the most up-to-date status that can be used as per your requirement.

Related issues

n/a

Release Summary

n/a

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes 🔥
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

  1. iOS test cases

ios

  1. Android test cases

android


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@CLAassistant
Copy link

CLAassistant commented Sep 13, 2022

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Sep 13, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-native-firebase ✅ Ready (Inspect) Visit Preview Sep 13, 2022 at 5:01AM (UTC)
1 Ignored Deployment
Name Status Preview Updated
react-native-firebase-next ⬜️ Ignored (Inspect) Sep 13, 2022 at 5:01AM (UTC)

@vercel
Copy link

vercel bot commented Sep 13, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-native-firebase-next 🔄 Building (Inspect) Sep 13, 2022 at 4:56AM (UTC)

@mikehardy
Copy link
Collaborator

Hey! Thanks for your patience on this - I'm still catching up (as fast as I can, but never fast enough...) after summer travels. Queued for review

@mikehardy mikehardy added the Workflow: Needs Review Pending feedback or review from a maintainer. label Sep 17, 2022
@codecov
Copy link

codecov bot commented Sep 17, 2022

Codecov Report

Merging #6529 (8030aba) into main (a05f63d) will decrease coverage by 17.75%.
The diff coverage is 88.89%.

❗ Current head 8030aba differs from pull request most recent head 8ea07fb. Consider uploading reports for the commit 8ea07fb to get more accurate results

@@              Coverage Diff              @@
##               main    #6529       +/-   ##
=============================================
- Coverage     72.30%   54.56%   -17.74%     
- Complexity        0      682      +682     
=============================================
  Files           109      208       +99     
  Lines          4657    10375     +5718     
  Branches       1048     1645      +597     
=============================================
+ Hits           3367     5660     +2293     
- Misses         1212     4433     +3221     
- Partials         78      282      +204     

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. For a little bit I was confused why the iOS implementation wasn't actually doing anything, then I remembered our previous conversation where it came out that on the iOS side you can only send things per-message + on receipt. At which point the property is perfect as it may be queried by an extension

Great work here, all around

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("isAutoInitEnabled", FirebaseMessaging.getInstance().isAutoInitEnabled());
constants.put("isDeliveryMetricsExportToBigQueryEnabled", FirebaseMessaging.getInstance().deliveryMetricsExportToBigQueryEnabled());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting - I was under the impression that constants were fetched once and cached such that setting new values into constants would not be reflected in future checks, but your test probes this, so, 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought at first. Gotta say that the tests were super helpful for a starter 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @mikehardy Hoping to contribute more in future!

@mikehardy mikehardy merged commit 930abd6 into invertase:main Sep 17, 2022
@mikehardy mikehardy removed the Workflow: Needs Review Pending feedback or review from a maintainer. label Sep 17, 2022
@mikehardy
Copy link
Collaborator

v15.6.0 just went out with this feature - good luck with your project!

@mattThousand
Copy link

mattThousand commented Sep 28, 2022

@mikehardy @pavan168 in order for an iOS app to export message data to BigQuery, I will still need to make my own Notification Service Extension, is that correct? But on Android, all I would need to do is call setDeliveryMetricsExportToBigQuery(true) from the javascript layer?

Or do the changes introduced in this PR mean that we no longer need to make our own Notification Service Extension?

I suppose I am a bit confused about how to use the changes introduced in this PR to send message data to BigQuery on iOS 🤔

@mikehardy
Copy link
Collaborator

I don't believe there is a way to avoid the extension on iOS bec you have to send it every notification. The PR made the status of user acceptance very accessible, but it still requires an extension. If this isn't clear in the docs you can hit the edit button at the top of any page and drop a note in to help future intrepid explorers 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants