Firebase InAppMessaging onClickListener not calling
i'm implementing FirebaseInAppMessagingClickListener and it's not working. While i tried with com.google.firebase:firebase-inappmessaging-display:17.2.0 and com.google.firebase:firebase-inappmessaging-display:18.0.2 And 'com.google.firebase:firebase-core:17.0.1'
I'm testing it and couldn't get any call of click listener. Using android targetSdkVersion 28.
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 have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.
@Abhishek-healthians this is not enough information to debug, we need to know exactly how something is "not working" and be able to reproduce it in order to be helpful to you.
Since it sounds like you just need some general help debugging your app, I would suggest trying StackOverflow.
@samtstern Please look into code. messageClicked call is not calling.
public class InAppMessageClick implements FirebaseInAppMessagingClickListener, FirebaseInAppMessagingImpressionListener, FirebaseInAppMessagingDisplay {
String TAG = "InAppMessageClick";
@Override
public void messageClicked(InAppMessage inAppMessage, Action action) {
// Determine which URL the user clicked
String url = action.getActionUrl();
LogUtils.i(TAG, "Action URL : "+url);
// Get general information about the campaign
CampaignMetadata metadata = inAppMessage.getCampaignMetadata();
System.out.println(TAG+" Metadata : "+metadata);
}
@Override
public void impressionDetected(InAppMessage inAppMessage) {
LogUtils.i(TAG, "impressionDetected Action URL : "+inAppMessage.getCampaignMetadata().getCampaignName());
}
@Override
public void displayMessage(InAppMessage inAppMessage, FirebaseInAppMessagingDisplayCallbacks firebaseInAppMessagingDisplayCallbacks) {
LogUtils.i(TAG, "displayMessage Action URL : "+inAppMessage.getCampaignMetadata().getCampaignName());
}
}
InAppMessageClick inAppMessageClick = new InAppMessageClick();
FirebaseInAppMessaging.getInstance().addClickListener(inAppMessageClick, new Executor() {
@Override
public void execute(Runnable command) {
LogUtils.i("MainActivity", "FIAM CLICKED EXECUTOR");
}
});
OR
InAppMessageClick inAppMessageClick = new InAppMessageClick();
FirebaseInAppMessaging.getInstance().addClickListener(inAppMessageClick);
i tried above both to register listener. But couldn't get call back.
@JasonAHeron and @MeghaB PTAL
Howdy @Abhishek-healthians, this was a bug we had in 17.2.0 specifically relating to the new card type message which we fixed in later versions. Please try updating to 18.0.2 and let me know if this is still an issue.
https://firebase.google.com/support/release-notes/android#version_1802
@JasonAHeron I tried a lot but it's not working. even after updating 18.0.2 (implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.2').
On Mon, Aug 5, 2019 at 11:17 PM Jason Heron [email protected] wrote:
Howdy @Abhishek-healthians https://github.com/Abhishek-healthians, this was a bug we had in 17.2.0 specifically relating to the new card type message which we fixed in later versions. Please try updating to 18.0.2 and let me know if this is still an issue.
https://firebase.google.com/support/release-notes/android#version_1802
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-android-sdk/issues/681?email_source=notifications&email_token=AMOHGJFSLY7IPBR5RYDH7OLQDBRSBA5CNFSM4II54JUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3SR3OY#issuecomment-518331835, or mute the thread https://github.com/notifications/unsubscribe-auth/AMOHGJGD547MZHZVFSNRO3TQDBRSBANCNFSM4II54JUA .
-- Regards, Abhishek Kumar Srivastav Android Developer, Healthians.com
Omega Centre, 1st Floor, A-26, Infocity, Sector 34, Gurgaon, Haryana - 122004
--
CONFIDENTIALITY INFORMATION: This e-mail message may contain
confidential or legally privileged information and is intended only for the use of the intended recipient(s). Any unauthorized disclosure, dissemination, distribution, copying or the taking of any action in reliance on the information herein is prohibited.
DISCLAIMER: E-mails are not secure and cannot be guaranteed to be error free as they can be intercepted, amended, or contain viruses. Anyone who communicates with us by e-mail is deemed to have accepted these risks. Healthians.com / Expedient Healthcare Marketing Pvt. Ltd. is not responsible for errors or omissions in this message and denies any responsibility for any damage arising from the use of e-mail. Any opinion and other statement contained
in this message and any attachment are solely those of the author and do not necessarily represent those of the company.
Is this for a specific message type? Can you click callbacks on modal for example but not card? or no message types at all?
Hi, I'm experiencing the same issue with all types. Looks like it never triggers click listeners.
I am unable to reproduce this issue with a debug app using the following code
mInAppMessaging?.addClickListener { inAppMessage, action ->
val campaignName = inAppMessage.campaignMetadata!!.campaignName
actionLog += "${logCounter++}) clicked: $campaignName, ${action.button?.text?.text}\n"
clickCount++
runOnUiThread {
messagesClickedNumber.text = clickCount.toString()
log.text = actionLog
}
}
how are you registering your onclick listener?
I tried to register listener right after getInstance call in Application.onCreate and MainActivity.onCreate like below.
FirebaseInAppMessaging.getInstance().addClickListener { inAppMessage, action ->
}
package com.example.fiamtestapp
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.iid.FirebaseInstanceId
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
import kotlinx.android.synthetic.main.activity_main.*
import com.google.firebase.analytics.FirebaseAnalytics
class MainActivity : AppCompatActivity() {
private var mInAppMessaging: FirebaseInAppMessaging? = null
private var mFirebaseAnalytics: FirebaseAnalytics? = null
private var impressionCount = 0
private var logCounter = 0
private var clickCount = 0
private var dismissCount = 0
private var actionLog = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this)
mInAppMessaging = FirebaseInAppMessaging.getInstance()
titleField.text = "FIAM version: ${BuildConfig.INAPPMESSAGING_VERSION}"
FirebaseInstanceId.getInstance().instanceId.addOnSuccessListener { instanceIdResult ->
instanceId.text = "InstanceID: ${instanceIdResult.id}"
}
mInAppMessaging?.addImpressionListener { inAppMessage ->
val campaignName = inAppMessage.campaignMetadata!!.campaignName
actionLog += "${logCounter++}) impressed: $campaignName\n"
impressionCount++
runOnUiThread {
messagesImpressedNumber.text = impressionCount.toString()
log.text = actionLog
}
}
mInAppMessaging?.addClickListener { inAppMessage, action ->
val campaignName = inAppMessage.campaignMetadata!!.campaignName
actionLog += "${logCounter++}) clicked: $campaignName, ${action.button?.text?.text}\n"
clickCount++
runOnUiThread {
messagesClickedNumber.text = clickCount.toString()
log.text = actionLog
}
}
mInAppMessaging?.addDisplayErrorListener { inAppMessage, error ->
val campaignName = inAppMessage.campaignMetadata!!.campaignName
actionLog += "${logCounter++}) error: $campaignName, ${error.name}\n"
runOnUiThread {
log.text = actionLog
}
}
}
}
So this is the only code in my simple test app. I cant repro your issue with this. Maybe it might help you. what message type are you using or just any of them?
FirebaseInAppMessaging.getInstance().addClickListener(
new FirebaseInAppMessagingClickListener() {
@Override
public void messageClicked(InAppMessage inAppMessage, Action action)
{
Toast.makeText(MainActivity.this, "IN APP MESSAGE CLICKED ", Toast.LENGTH_SHORT).show();
}
});
I tried this in onStart(). And it's again not working. I am using emulator. Is there any issue with emulator ?
Not working with latest sdk V19.0.0 implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.0'
I am using 'Card Style' to capture button taps. And trying to trigger 'Firebase InApp Messaging' using 'Test on device' button from console. (Debug Testing purpose)
Using this below code in my MainActivity.java 'onCreate()' function.
FirebaseInAppMessaging.getInstance().addClickListener(
new FirebaseInAppMessagingClickListener() {
@Override
public void messageClicked(@NonNull InAppMessage inAppMessage, @NonNull Action action) {
Timber.i("===> Inside onMessageClicked %s", inAppMessage.getCampaignMetadata().getCampaignName());
// Determine which URL the user clicked
String url = action.getActionUrl();
// Get general information about the campaign
CampaignMetadata metadata = inAppMessage.getCampaignMetadata();
// ...
}
});
This "Inside onMessageClicked" is never getting logged. FYI i could see the card style popup in my MainActivity.java
Hi all!
The Test on Device feature is mainly intended for previewing the visuals - the callbacks aren't triggered for test messages, to avoid contaminating your analytics/callbacks flows with test data.
However, that's an interesting use case, and we're discussing adding it to the road map!
I have a change that will enable callbacks for test on device messages in the coming release. Sorry about the confusion here.