If you are using firebase cloud messaging, in TWA you can use web pushes, receiving them on your site, or android native pushes, receiving them in your application.
My experiments have shown web pushes very unreliable. They are actually received by chrome and depends on chrome settings and policies. Very likely they won't be shown as notification popup with sound, only as the notification icon.
Alternatively you can write a bit more complex application, which uses firebase android sdk and receives native pushes. Native pushes are completelly reliable, you can control their importance and look as you wish.
You will have to create the main activity manually, and place there any startup code you need:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// override the default channel settings
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create channel to show notifications.
String channelId = getString(R.string.default_notification_channel_id);
String channelName = getString(R.string.default_notification_channel_name);
NotificationManager notificationManager =
getSystemService(NotificationManager.class);
// override the default channel importance to make notifications show as popup with sound
notificationManager.createNotificationChannel(new NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_HIGH));
}
//
// here you can get the device registration token and send it to your backend
// or do any additional processing
//
// now everithing is set up and we can start the twa activity
Intent intent = new Intent(this, com.google.androidbrowserhelper.trusted.LauncherActivity.class);
intent.setData(Uri.parse("http://www.google.com"));
startActivity(intent);
}
Some more details on starting TWA activity programmatically in this post: https://mcmap.net/q/1180869/-cannot-understand-how-to-open-a-simple-twa-inside-an-app-using-androidx