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: add new feature to app identifier to push notification payload #35686

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

AtharvShelke
Copy link

@AtharvShelke AtharvShelke commented Apr 2, 2025

feat: add app identifier to push notification payload (#35685)
Proposed changes
This PR ensures that the app identifier (appName) is included in the push notification payload for the GCM endpoint. Currently, the identifier is only included in the APN payload as topic, but it is missing from GCM.

To improve app-specific handling and allow the push gateway to correctly distinguish between different apps (official Rocket.Chat app and white-labeled versions), this update adds appName to the GCM payload while keeping topic available for its intended purpose.

Changes made:
Added appName to the GCM push notification payload.

Ensured consistency between APN and GCM by including the app identifier in both.

Issue(s)
Closes #35685

Steps to test or reproduce

  1. Set up a Rocket.Chat instance with push notifications enabled for both APN and GCM.

  2. Send a push notification and inspect the payload.

  3. Verify that the appName field is present in the GCM payload and correctly identifies the app.

Further comments
This change improves push notification handling for both the official Rocket.Chat app and custom white-labeled versions. Feedback is welcome, and I’m happy to make any necessary adjustments!

Copy link
Contributor

dionisio-bot bot commented Apr 2, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Apr 2, 2025

⚠️ No Changeset found

Latest commit: 59fe69e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Apr 2, 2025

CLA assistant check
All committers have signed the CLA.

@AtharvShelke AtharvShelke changed the title Add App Identifier to Push Notification Payload #35685 feat: add app identifier to push notification payload (#35685) Apr 2, 2025
@AtharvShelke AtharvShelke changed the title feat: add app identifier to push notification payload (#35685) feat: add app identifier to push notification payload Apr 2, 2025
@AtharvShelke AtharvShelke changed the title feat: add app identifier to push notification payload feat: add new feature to app identifier to push notification payload Apr 2, 2025
Copy link

@NikoHadouken NikoHadouken left a comment

Choose a reason for hiding this comment

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

The type GatewayNotification should be updated to reflect the new appName property.

I also found that the type GatewayNotification (that probably was copy pasted from the push gateway code) can be misleading because it diverges from the data that is sent to the endpoint which is essentially just PendingPushNotification.

This might be a more fitting type description but this change should probably be put in another issue/PR:

type GatewayNotification = Omit<PendingPushNotification, 'priority'> & {
	uniqueId: string
	appName: string
	topic?: string
}

Comment on lines 340 to 354
if ('apn' in app.token && app.token.apn) {
countApn.push(app._id);
return this.sendGatewayPush(gateway, 'apn', app.token.apn, {
topic: app.appName,
...gatewayNotification
});
}

if ('gcm' in app.token && app.token.gcm) {
countGcm.push(app._id);
return this.sendGatewayPush(gateway, 'gcm', app.token.gcm, {
appName: app.appName, // Add appName field
...gatewayNotification
});
}

Choose a reason for hiding this comment

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

I would update getGatewayNotificationData, pass app: IAppsTokens as argument and move the entire logic to create the payload there:

  • set topic for apn
  • set appName for both apn and gcm for consistency

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.

Add App Identifier to Push Notification Payload
4 participants