Skip to content

feat(fcm): Support apns.live_activity_token field in FCM ApnsConfig #2891

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

janodetzel
Copy link

  • feat(fcm): Support live_activity_token field on ApnsConfig
  • added validation
  • update documentation

Fixes #2875

@@ -1725,6 +1725,21 @@ describe('Messaging', () => {
});
});

const invalidApnsLiveActivityTokens: any[] = [null, NaN, 0, 1, true, false]

Choose a reason for hiding this comment

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

perhaps we should add a test for valid payload?

Copy link
Author

Choose a reason for hiding this comment

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

Sure thing. I added the tests with valid payloads for the live activity start | update | end events

Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! Could you change the new property to lowerCamelCase formatting?
Can you also run npm run api-extractor:local? That would update the api docs and should fix the CI errors. Thanks!

/**
* APN `live_activity_push_to_start_token` or `live_activity_push_token` to start or update live activities.
*/
live_activity_token?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Exported names should be in lowerCamelCase formatting. Could you change this to liveActivityToken instead?

Copy link
Author

@janodetzel janodetzel May 13, 2025

Choose a reason for hiding this comment

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

Makes sense, thanks for your review!
I am not quite sure where to map the property liveActivityToken to live_activity_token as required for the HTTP API? https://firebase.google.com/docs/cloud-messaging/ios/live-activity

Copy link
Author

Choose a reason for hiding this comment

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

also: Should the additional fields like dismissal-date content-state or attributes-type also get included and mapped? Those could also be [customData: string]: any typed

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @janodetzel, The mapping should be done inside validateApnsConfig() in messaging-internal.ts. You can use validateAndroidConfig() for reference:

const propertyMappings = {
collapseKey: 'collapse_key',
restrictedPackageName: 'restricted_package_name',
directBootOk: 'direct_boot_ok',
};
renameProperties(config, propertyMappings);

As for additional fields, like you said the customData field should be sufficient to over any needed payload fields, so lets leave those out for now.

Copy link
Author

@janodetzel janodetzel May 30, 2025

Choose a reason for hiding this comment

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

Hey @jonathanedey. Amazing, thank you for this info! I implemented the property mapping and adjusted the tests.

* feat(fcm): Support `live_activity_token` field on `ApnsConfig`
* added validation
* update documentation
@janodetzel janodetzel force-pushed the master branch 2 times, most recently from 756c68d to 1d032bd Compare May 30, 2025 20:37
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.

Missing fields in apns type definition for FCM live activities
6 participants