feat(notifications): add backend-agnostic push notifications common module#3338
Draft
ekjotmultani wants to merge 1 commit into
Draft
feat(notifications): add backend-agnostic push notifications common module#3338ekjotmultani wants to merge 1 commit into
ekjotmultani wants to merge 1 commit into
Conversation
…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 Report❌ Patch coverage is 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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
aws-push-notifications-common, a backend-agnostic library of Android push notification primitives. It is a Pinpoint-free successor toaws-push-notifications-pinpoint-common, providing the same building blocks without any coupling to Amazon Pinpoint or the AWS SDK.The module provides:
PushNotificationPayload): builds a displayable payload from aNotificationPayload, a raw FCM data map, aRemoteMessage, or anIntent, 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.PushNotificationsUtils):showNotificationbacked byNotificationCompat, plusisAppInForegroundandareNotificationsEnabled.PushNotificationPermission,PermissionRequestResult):POST_NOTIFICATIONShandling for API 33+.PushNotificationsConstants,PushNotificationChannels): the generic payload keys and a notification channel DSL.The public
NotificationPayloadandNotificationContentProvidertypes continue to come fromcommon-coreand are re-exported, so consumers get them transitively.Why
This is a foundation library that other consumers depend 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 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, andfirebase-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
mainafter rebase.Open questions for reviewers
@InternalAmplifyApi(ERROR level opt-in). Making it public means consumers can drop their@OptInannotations, 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-messagingas anapidependency.PushNotificationPayload.fromRemoteMessage(RemoteMessage)exposes a Firebase type, sofirebase-messagingis currently anapidependency and leaks transitively. If we would rather keep Firebase off the public surface, I can drop that overload and keep onlyfromData(Map<String, String>), which is what the RN bridge already uses.