Skip to content

Conversation

@simonbullen
Copy link

@simonbullen simonbullen commented Jun 24, 2025

Adds new interface CustomInAppDisplayProvider with InAppController support to allow applications to display CTInAppNotifications themselves.

This allows the CleverTap Unreal Plugin to support the Custom-Html Header & Footer InApp notification types despite being unable to provide a FragmentActivity:

See the HtmlBannerInAppDisplayProvider implementation in the CleverTap Unreal SDK:
CleverTap/clevertap-unreal-sdk#24

Summary by CodeRabbit

  • New Features
    • Added support for custom in-app notification display, enabling activities to handle and render notifications with their own logic.
    • Introduced callbacks for custom providers to report user interactions and notification lifecycle events back to the system.

…plications to display CTInAppNotifications themselves..
@francispereira
Copy link

francispereira commented Jun 24, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

@simonbullen simonbullen marked this pull request as ready for review June 24, 2025 04:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

A new extension point for custom in-app notification display is introduced. This involves adding the CustomInAppDisplayProvider interface for activities to handle in-app notifications, and updating InAppController to delegate notification display to this provider if available, forwarding user interaction callbacks accordingly.

Changes

File(s) Change Summary
.../sdk/inapp/InAppController.java Added tryCustomShowInApp method; modified showInApp to delegate to custom display provider if available.
.../sdk/interfaces/CustomInAppDisplayProvider.java Introduced new interface CustomInAppDisplayProvider with nested Callbacks for custom in-app notification UI.

Sequence Diagram(s)

sequenceDiagram
    participant InAppController
    participant Activity
    participant CustomInAppDisplayProvider
    participant User

    InAppController->>Activity: Check if implements CustomInAppDisplayProvider
    alt Activity implements provider and canDisplay
        InAppController->>CustomInAppDisplayProvider: display(notification, config, host, callbacks)
        CustomInAppDisplayProvider->>User: Display custom in-app notification
        User->>CustomInAppDisplayProvider: Interact (action/button/dismiss/show)
        CustomInAppDisplayProvider->>InAppController: Callbacks (onActionTriggered/onButtonClicked/onDismissed/onShown)
    else Not handled by custom provider
        InAppController->>InAppController: Proceed with default in-app display logic
    end
Loading

Suggested reviewers

  • piyush-kukadiya
  • darshanclevertap

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2e9ae8 and a1e6b89.

📒 Files selected for processing (1)
  • clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java (1)

880-920: Consider adding error handling for robustness.

The implementation correctly follows the interface contract and properly forwards callbacks to existing methods. However, consider adding error handling around the custom provider calls to prevent potential crashes from faulty implementations.

Consider wrapping the custom provider calls in try-catch blocks:

 private boolean tryCustomShowInApp(CTInAppNotification notification) {
     Activity activity = CoreMetaData.getCurrentActivity();
     if (activity == null || !(activity instanceof CustomInAppDisplayProvider) ) {
         return false; // not a CustomInAppDisplayProvider
     }
     CustomInAppDisplayProvider displayProvider = (CustomInAppDisplayProvider) activity;
-    if (!displayProvider.canDisplay(notification, config, activity)) {
-        return false; // not supported/wanted
-    }
-    displayProvider.display(notification, config, activity, new CustomInAppDisplayProvider.Callbacks() {
+    try {
+        if (!displayProvider.canDisplay(notification, config, activity)) {
+            return false; // not supported/wanted
+        }
+        displayProvider.display(notification, config, activity, new CustomInAppDisplayProvider.Callbacks() {
             @Override
             public Bundle onActionTriggered(@NonNull CTInAppNotification notification,
                     @NonNull CTInAppAction action,
                     @NonNull String callToAction,
                     Bundle additionalData,
                     Context activityContext) {
                 return inAppNotificationActionTriggered(notification, action, callToAction, additionalData,
                         activityContext);
             }

             @Override
             public void onButtonClicked(@NonNull CTInAppNotification notification, CTInAppNotificationButton button,
                     Context activityContext) {
                 inAppNotificationDidClick(notification, button, activityContext);
             }

             @Override
             public void onDismissed(@NonNull CTInAppNotification notification, Bundle formData) {
                 inAppNotificationDidDismiss(notification, formData);
             }

             @Override
             public void onShown(@NonNull CTInAppNotification notification, Bundle formData) {
                 inAppNotificationDidShow(notification, formData);
             }
-        });
+        });
+    } catch (Exception e) {
+        logger.debug(config.getAccountId(), "Error in custom in-app display provider: " + e.getMessage(), e);
+        return false; // fall back to standard display
+    }

     return true; // handled
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80038e8 and f2e9ae8.

📒 Files selected for processing (2)
  • clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java (3 hunks)
  • clevertap-core/src/main/java/com/clevertap/android/sdk/interfaces/CustomInAppDisplayProvider.java (1 hunks)
🔇 Additional comments (3)
clevertap-core/src/main/java/com/clevertap/android/sdk/interfaces/CustomInAppDisplayProvider.java (1)

1-64: Excellent interface design and documentation!

The CustomInAppDisplayProvider interface is well-designed with clear separation of concerns:

  • The two-phase pattern (canDisplay()display()) allows providers to opt-in selectively
  • The Callbacks interface properly mirrors the existing InAppController methods for seamless integration
  • Comprehensive documentation explains the contract and requirements
  • Consistent use of @NonNull annotations ensures null safety

This provides a clean extension point for custom in-app notification handling while maintaining compatibility with existing analytics and queue management.

clevertap-core/src/main/java/com/clevertap/android/sdk/inapp/InAppController.java (2)

45-45: Clean integration with existing imports.

The import is appropriately placed and follows the existing import organization.


798-800: Proper integration point with early return pattern.

The integration correctly uses an early return pattern to bypass standard display logic when a custom provider handles the notification. This maintains backward compatibility while enabling the new functionality.

simonbullen added a commit to CleverTap/clevertap-unreal-sdk that referenced this pull request Jun 26, 2025
…tions (#24)

Adds HtmlBannerInAppDisplayProvider to handle the display of custom-html header & footer banner-notifications.
The normal CleverTap implementation relies on a FragmentActivity which unreal can't easily support.

This functionality requires adding the CustomInAppDisplayProvider interface to the clevertap android sdk.
CleverTap/clevertap-android-sdk#839

This PR includes (and defaults to) a prebuilt clevertap-android-sdk.aar with this pre-release functionality included.
The AAR will be removed when the maven version has the needed features.
@vasct vasct closed this Jul 9, 2025
@vasct
Copy link
Contributor

vasct commented Jul 9, 2025

The changes in this PR are not needed anymore. See #841

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.

3 participants