Skip to content

Add AJO Basic push notification template support#437

Open
ritusingh-29 wants to merge 7 commits into
adobe:mainfrom
ritusingh-29:feature/ajo-basic-template
Open

Add AJO Basic push notification template support#437
ritusingh-29 wants to merge 7 commits into
adobe:mainfrom
ritusingh-29:feature/ajo-basic-template

Conversation

@ritusingh-29

@ritusingh-29 ritusingh-29 commented Jun 5, 2026

Copy link
Copy Markdown

Summary

Wires the Messaging SDK to the notificationbuilder library so AJO push notification template payloads are rendered via the new AJO template system, while leaving the existing push flow completely untouched.

The integration point is MessagingService.handleRemoteMessage():

  • AJO template payload — when adb_template_type is present in the FCM data map, rendering is delegated to NotificationBuilder.constructNotificationBuilder(...).build().
  • Existing payload — when the key is absent, the current MessagingPushPayloadMessagingPushBuilder path runs exactly as before.

Background

The existing Messaging push flow (MessagingPushPayload + MessagingPushBuilder) was built for the established flat-key push payload shape. AJO templated payloads carry an adb_template_type key plus an adb_template_properties JSON blob for template-specific configuration.

Rather than fork MessagingPushBuilder, template rendering is delegated entirely to the notificationbuilder library, which owns the template parsing and layout logic. See companion PR in aepsdk-ui-android.

What changed

File Change
MessagingService.java handleRemoteMessage() now branches on adb_template_type. If present, it delegates to NotificationBuilder.constructNotificationBuilder(data, MessagingPushTrackerActivity.class, NotificationInteractionReceiver.class).build(), wrapped in a try/catch on NotificationConstructionFailedException / IllegalArgumentException that logs a warning and drops the message on failure. If absent, the existing MessagingPushPayload + MessagingPushBuilder.build(...) path is used unchanged.
MessagingConstants.java New TEMPLATE_TYPE = "adb_template_type" constant in Push.PayloadKeys, used as the routing signal.
build.gradle.kts New dependency on the notificationbuilder library. Version to be bumped once aepsdk-ui-android releases AJO template support.
MainActivity.kt (testapp) Added "Test AJO Basic Push" button listener, showAjoBasicPicker() — a dialog listing every JSON in assets/ajo_basic/ — and fireAjoBasicPush(), which loads a JSON asset into a Map<String, String> and calls MessagingService.handleRemoteMessage() directly, simulating an FCM delivery without a live Firebase connection. Also added Assurance deep-link handling (Assurance.startSession) in onCreate and onNewIntent.
activity_main.xml (testapp) Added btnTestAjoBasic button to the testapp UI.
AndroidManifest.xml (testapp) Added a deep-link intent-filter for the messagingsample:// scheme, required for Assurance session start via QR code / URL.
ajo_basic_center_crop.json (testapp asset) Sample ajo_basic payload with scale_type: center_crop for manual testing.
ajo_basic_fit_center.json (testapp asset) Sample ajo_basic payload with scale_type: fit_center for manual testing.

Payload schema (ajo_basic)

FCM data map: flat Map<String, String>.

{
  "adb_template_type": "ajo_basic",
  "adb_title": "<title fallback>",
  "adb_body": "<body fallback>",
  "adb_image": "<image url fallback>",
  "adb_icon": "ic_launcher_background",
  "adb_sound": "bells",
  "adb_channel_id": "ajo_basic_channel",
  "adb_n_count": "1",
  "adb_n_priority": "PRIORITY_HIGH",
  "adb_n_visibility": "PUBLIC",
  "adb_a_type": "WEBURL",
  "adb_uri": "https://www.adobe.com",
  "adb_act": "[{\"label\":\"Learn More\",\"uri\":\"https://www.adobe.com\",\"type\":\"WEBURL\"},{\"label\":\"Open App\",\"uri\":\"\",\"type\":\"OPENAPP\"}]",
  "_xdm": "<tracking token>",
  "adb_template_properties": {
    "adb_version": "1",
    "adb_title": {
      "text": "<title>"
    },
    "adb_body": {
      "text": "<body>"
    },
    "adb_image": {
      "url": "<image url>",
      "scale_type": "center_crop | fit_center"
    },
    "adb_large_icon": {
      "url": "<icon url>",
      "scale_type": "center_crop | fit_center"
    }
  }
}

Values in adb_template_properties take precedence. Flat keys serve as fallback for backward compatibility.

How Has This Been Tested?

Tested manually via the testapp by firing ajo_basic payloads with both center_crop and fit_center scale types across the following aspect ratios:

  • 1:1
  • 3:2
  • 5:4
  • 4:3
  • 2:1
  • 16:9

Devices / API levels tested

Device API Result
Pixel 6 API 34 / Android 14 ✅ Both scale types render correctly
Pixel 6 Tablet API 34 / Android 14 ✅ Both scale types render correctly
Pixel 5 API 31 / Android 12 ✅ Both scale types render correctly
Pixel 3a API 26 / Android 8 ✅ Both scale types render correctly
Pixel API 21 / Android 5 ⚠️ Image does not render

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@navratan-soni

Copy link
Copy Markdown
Contributor

Add a jira ticket to also add new templates in aepsdk-ui-android

#Thu Jun 04 12:49:37 CDT 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove these cahnge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should not have this changed

final String templateType =
remoteMessage.getData().get(MessagingConstants.Push.PayloadKeys.TEMPLATE_TYPE);

if (!StringUtils.isNullOrEmpty(templateType)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this logic entirely in MessagingPushBuilder

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.

2 participants