firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

Override behavior of In-App message

Open garispe opened this issue 3 years ago • 9 comments

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Arctic Fox 2020.3.1 Patch 3
  • Firebase Component: In-App Messaging
  • Component version: com.google.firebase:firebase-bom:28.3.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

I created a Firebase In-App messaging campaign from console and I used addClickListener() to override behavior of primary button action. When I receive the in-app message and click primary button, my custom listener is invoked correctly but the Firebase SDK opens the link from campaign.

I need to attach dynamic information to the link configured in the Firebase console and then open the composed link.

The problem is in this line because when I override the click behavior, the SDK invokes launchUriIntent(activity, Uri.parse(action.getActionUrl())); anyway

Relevant Code:

I think that the fix can be something like that:

@Override
public void onClick(View v) {
    if (callbacks != null) {
        Logging.logi("Calling callback for click action");
        callbacks.messageClicked(action);
    } else {    <====== THIS ELSE
        launchUriIntent(activity, Uri.parse(action.getActionUrl()));
    }
   
    notifyFiamClick();
    // Ensure that we remove the displayed FIAM, and ensure that on re-load, the message
    // isn't re-displayed
    removeDisplayedFiam(activity);
    inAppMessage = null;
    callbacks = null;
}

In this way, the SDK delegates the behavior to the custom listener

garispe avatar Oct 14 '21 14:10 garispe

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Oct 14 '21 14:10 google-oss-bot

Hi @garispe Thanks for pointing this out. We will check on this solution and get back. In the mean time, do you want to come up with a Pull Request?

aguatno avatar Oct 15 '21 18:10 aguatno

Hi @aguatno Thanks for your reply. I can create the corresponding PR but I don't know if it's the expected behavior from Firebase because iOS works in the same way. If this is correct, I'll need to manage this issue locally in my app. Do you think that is an unexpected behavior?

garispe avatar Oct 15 '21 19:10 garispe

I faced the same issue if I used this listener "messageClicked" I don't want any other behaviour @garispe your solution is perfect

AbdulrhmanKassemSalla avatar May 12 '22 03:05 AbdulrhmanKassemSalla

@AbdulrhmanKassemSalla I already opened a PR to fix this

garispe avatar May 12 '22 14:05 garispe

Hi @garispe, thank you for submitting a PR for this! I was able to test this and it works nicely.

I'm not sure if this is an intended behavior or an actual bug, I'll notify an engineer to see if we can get your PR approved or if there are changes needs to be done.

argzdev avatar May 13 '22 12:05 argzdev

Hi @argzdev, thanks!

I look forward to the review. It would be great if that behavior could be modified.

garispe avatar May 13 '22 13:05 garispe

Hi @garispe , Thanks for reaching out on this and for the PR.

The event listeners mentioned here are for the purpose of tracking the user interactions and not for overriding them. For example when the user interacts with an inapp message and is getting navigated to a web url, if the developer wants to track the navigation, then they can use these listeners. Sorry for the mis understanding here.

But however we understand the developers need for having custom handling of inapp message and so we will consider this in our upcoming features ie. to support inapp message customization and handling.

eldhosembabu avatar May 16 '22 18:05 eldhosembabu

Hey @garispe. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar May 23 '22 01:05 google-oss-bot

Hi @garispe , Thanks for reaching out on this and for the PR.

The event listeners mentioned here are for the purpose of tracking the user interactions and not for overriding them. For example when the user interacts with an inapp message and is getting navigated to a web url, if the developer wants to track the navigation, then they can use these listeners. Sorry for the mis understanding here.

But however we understand the developers need for having custom handling of inapp message and so we will consider this in our upcoming features ie. to support inapp message customization and handling.

@eldhosembabu Please note there is also a limitation in the current deep link mechanism if and when the campaign has custom data (key value pairs) specified. This isn't passed to the activity handling the deep link. However, these custom data is available in the click listener via getData

Screenshot 2023-05-15 at 8 39 50 PM

Ethan1983 avatar May 16 '23 21:05 Ethan1983