Custom headers with TWALauncher
Hi,
I have built a TWA app that uses the TwaLauncher to launch.
I'm currently in a position where I need to send a token that was stored in a previous version of the native app to the web site which I'm starting. I thought the most suitable way to do this was to send it as a custom header.
So I took a look at the Custom Headers Demo and eventually got it working in my app.
However, the only way forward I could see was to copy the code from TwaLauncher into my own app and modify it.
Besides adding the handle_all_urls relationship to my asset statements, it seems as if client.warmup is always required as well as mSession.validateRelationship(CustomTabsService.RELATION_USE_AS_ORIGIN, URL, null)
To avoid having to "own" all the TwaLauncher code, I guess I'm requesting some way to tell it to set up the extra validation for me. Or am I missing something?
Best Regards Tobias
Looks like there isn't an easy way to invoke validateRelationship() from TwaLauncher. This seems like a valid feature request.
So this means there is no way at present to add any extra headers using TwaLauncher?
It looks like this is where the intent gets picked up, TrustedWebActivityIntent.build:
Intent intent = mIntentBuilder.build().intent;
And we don't have access to the CustomTabsIntent.Builder, so there is no way to, for example to: headers.putString("bearer-token", "Some token")?
Does that then mean the only solution, if I am needing to add a Cookie header, is to use a chrome custom tab solution outlined in the CCT Custom Headers demo, rather than a TwaLauncher?
Or am I misinterpreting?