Read this First
If you have a Trusted Web Activity related question, the best place to ask it is on StackOverflow, on the
trusted-web-activity tag, which is also monitored by the team.
Describe the bug
CustomTabsCallback onMessageChannelReady is not getting called even if the validation result is true.
Why do we have !mValidated condition in onNavigationEvent if onRelationshipValidationResult gets triggered only when mSession.requestPostMessageChannel is called from the function.
@Override
public void onRelationshipValidationResult(int relation, @NonNull Uri requestedOrigin,
boolean result, @Nullable Bundle extras) {
// If this fails:
// - Have you called warmup?
// - Have you set up Digital Asset Links correctly?
// - Double check what browser you're using.
Log.d(TAG, "==========Relationship result============: " + result);
mValidated = result;
}
// Listens for navigation, requests the postMessage channel when one completes.
@Override
public void onNavigationEvent(int navigationEvent, @Nullable Bundle extras) {
if (navigationEvent != NAVIGATION_FINISHED) {
return;
}
if (!mValidated) {
Log.d(TAG, "Not starting PostMessage as validation didn't succeed.");
}
// If this fails:
// - Have you included PostMessageService in your AndroidManifest.xml?
boolean result = mSession.requestPostMessageChannel(SOURCE_ORIGIN, TARGET_ORIGIN,
new Bundle());
Log.d(TAG, "Requested Post Message Channel: " + result);
}
@Override
public void onMessageChannelReady(@Nullable Bundle extras) {
Log.d(TAG, "Message channel ready.");
int result = mSession.postMessage("First message", null);
Log.d(TAG, "postMessage returned: " + result);
}
Read this First If you have a Trusted Web Activity related question, the best place to ask it is on StackOverflow, on the trusted-web-activity tag, which is also monitored by the team.
Describe the bug
mSession.requestPostMessageChannel
is called from the function.