How display Firebase In-App Messaging on TWA?

139 Views Asked by At

I tried to display In-App Messaging but it didn't show up with TWA. In-App Messaging works without any problems with normal Activity.

I use https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/twa-basic to test TWA.

My application is correctly configured with Firebase. I created a campaign.enter image description here

My logs after publishing the campaign: ``

I closed my application and then launched it and I didn't see In-App Messaging.

I tested another application with a standard Activity and there was no problem displaying In-App Messaging.

enter image description here

1

There are 1 best solutions below

0
tesst On

I took a lot of time today to answer this question for myself.

In my opinion TWA can't work with In-App Messaging. I am not an Android programmer and I could be wrong.

This is my test Activity:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    FirebaseInAppMessaging.getInstance().setMessagesSuppressed(true);
}

public void onClick(View view) {
    CampaignMetadata campaignMetadata = new CampaignMetadata("test_campaign", "name", true);
    Text title =  Text.builder().setText("test").setHexColor("#000000").build();
    Text body =  Text.builder().setText("test").setHexColor("#000000").build();

    ModalMessage message = ModalMessage.builder()
            .setBackgroundHexColor("#ffffff")
            .setTitle(title)
            .setBody(body)
            .build(campaignMetadata, null);

    FirebaseInAppMessagingDisplay.getInstance().testMessage(this, message, null);

    FirebaseInAppMessaging.getInstance().setMessagesSuppressed(false);
}

@Override
protected void onResume() {
    super.onResume();
}

}

To display In App Messaging we need a Activity. I think we can only In App Messaging display on splash screen TWA but i didn't try it.

enter image description here