Skip to content

feat(notifications): add backend-agnostic push notifications common module#3338

Draft
ekjotmultani wants to merge 1 commit into
mainfrom
feat/push-notifications-common
Draft

feat(notifications): add backend-agnostic push notifications common module#3338
ekjotmultani wants to merge 1 commit into
mainfrom
feat/push-notifications-common

Conversation

@ekjotmultani

Copy link
Copy Markdown
Member

Summary

Adds aws-push-notifications-common, a backend-agnostic library of Android push notification primitives. It is a Pinpoint-free successor to aws-push-notifications-pinpoint-common, providing the same building blocks without any coupling to Amazon Pinpoint or the AWS SDK.

The module provides:

  • Generic FCM payload parsing (PushNotificationPayload): builds a displayable payload from a NotificationPayload, a raw FCM data map, a RemoteMessage, or an Intent, reading standard payload keys (title, body, imageUrl, url, deeplink, openApp, channelId, silentPush). It parses plain FCM pushes that carry no backend-specific keys and never drops them, so a valid non-Pinpoint push is still displayable.
  • Notification display (PushNotificationsUtils): showNotification backed by NotificationCompat, plus isAppInForeground and areNotificationsEnabled.
  • Permissions (PushNotificationPermission, PermissionRequestResult): POST_NOTIFICATIONS handling for API 33+.
  • Constants and channel helpers (PushNotificationsConstants, PushNotificationChannels): the generic payload keys and a notification channel DSL.

The public NotificationPayload and NotificationContentProvider types continue to come from common-core and are re-exported, so consumers get them transitively.

Why

This is a foundation library that other consumers depend on:

  • The Amplify JavaScript React Native Android bridge currently depends on aws-push-notifications-pinpoint-common. This module gives it a Pinpoint-free replacement so it can migrate off Pinpoint with close to a dependency swap.
  • The Flutter Android push layer, which today routes through the Pinpoint-specific parser and drops non-Pinpoint FCM pushes, can consume this instead to fix that gap.
  • Native app developers who want the low level pieces directly.

The public symbol names and shapes are kept aligned with what these consumers already import so the migration stays small.

Dependencies

Depends only on common-core, annotations, androidx, and firebase-messaging. No AWS SDK and no Pinpoint dependency.

Testing

16 unit tests, all passing, including a regression guard that a payload with no Pinpoint keys is parsed and not dropped. Build, ktlintCheck, apiCheck, and lintRelease all pass against current main after rebase.

Open questions for reviewers

  • Public vs internal API surface. The successor API is exposed as a clean public API, whereas the original Pinpoint payload and constants were marked @InternalAmplifyApi (ERROR level opt-in). Making it public means consumers can drop their @OptIn annotations, but it also commits us to binary compatibility on these symbols. Happy to mark them internal instead if we would rather not commit yet.
  • firebase-messaging as an api dependency. PushNotificationPayload.fromRemoteMessage(RemoteMessage) exposes a Firebase type, so firebase-messaging is currently an api dependency and leaks transitively. If we would rather keep Firebase off the public surface, I can drop that overload and keep only fromData(Map<String, String>), which is what the RN bridge already uses.

…odule

Introduce aws-push-notifications-common, a vendor-neutral library of push
notification primitives that does not depend on any specific backend.

It provides:
- PushNotificationPayload: parses a NotificationPayload / FCM data map /
  RemoteMessage / Intent into a displayable payload using standard payload
  keys. Unlike the previous parser it never drops a valid FCM message, so
  pushes without backend-specific keys are parsed and displayed.
- PushNotificationsUtils: showNotification, isAppInForeground and
  areNotificationsEnabled backed by NotificationCompat.
- PushNotificationPermission and PermissionRequestResult for POST_NOTIFICATIONS
  handling on API 33+.
- PushNotificationsConstants and the notification channel DSL.

The public NotificationPayload and NotificationContentProvider types continue
to come from common-core and are re-exported. Depends only on common-core and
androidx/firebase-messaging.
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.64646% with 169 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.19%. Comparing base (88e51cb) to head (6affd40).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3338      +/-   ##
==========================================
- Coverage   56.44%   56.19%   -0.25%     
==========================================
  Files        1088     1095       +7     
  Lines       32175    32373     +198     
  Branches     4799     4830      +31     
==========================================
+ Hits        18162    18193      +31     
- Misses      12124    12289     +165     
- Partials     1889     1891       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant