firebase / firebase/firebase-android-sdk
Override behavior of In-App message
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 710
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 34
Description
### [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](https://github.com/firebase/firebase-android-sdk/blob/e1f356a87ed506f765df4f4a2f3c93daae44f2aa/firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplay.java#L322) 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:
```java
@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
Contributor guide
Research direction
Read firebase-inappmessaging-display/src/main/java/com/google/firebase/inappmessaging/display/FirebaseInAppMessagingDisplay.java around line 322 and trace the addClickListener() path. Confirm that a custom click listener can handle the action without also opening the campaign URL, while the click notification and message cleanup still occur.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100