我正在使用FirebaseInAppMessaging并且它有效。然后我使用 注册动作回调FirebaseInAppMessagingClickListener
,它没有调用。
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();
Log.i(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());
}
}
我在 MainActivity 的 onCreate 中注册了这个点击监听器
InAppMessageClick inAppMessageClick = new InAppMessageClick();
FirebaseInAppMessaging.getInstance().setMessageDisplayComponent(inAppMessageClick);
FirebaseInAppMessaging.getInstance().addClickListener(inAppMessageClick);
我试图通过两种方式注册监听器。
InAppMessageClick inAppMessageClick = new InAppMessageClick();
FirebaseInAppMessaging.getInstance().addClickListener(inAppMessageClick);`
或者
FirebaseInAppMessaging.getInstance().addClickListener(inAppMessageClick, new Executor() {
@Override
public void execute(Runnable command) {
LogUtils.i("MainActivity", "FIAM CLICKED EXECUTOR");
}
});
`
并使用 gradle
implementation 'com.google.firebase:firebase-inappmessaging-display:18.0.2'
implementation 'com.google.firebase:firebase-core:17.0.1'