Implementation of PostMessage for TWA android application

135 views Asked by At

Used this documentation. Works. https://developer.chrome.com/docs/android/post-message-twa

BUT! If we change "relation" in assetlinks.json: ["delegate_permission/common.handle_all_urls"] to "relation": ["delegate_permission/common.use_as_origin"], as indicated in the article - the address bar appears in the application.

How to fix?

1

There are 1 answers

1
shunxing On

You can specify multiple ones in the json

[
  {
    "relation": ["delegate_permission/common.use_as_origin"],
    "target": {
      "namespace": "android_app",
      "package_name": "your package name",
      "sha256_cert_fingerprints": ["your sha 256"]
    }
  },
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "your package name",
      "sha256_cert_fingerprints": ["your sha 256"]
    }
  }
]

However I have the issue that it's not reaching onMessageChannelReady.

If I call requestPostMessageChannel in onCustomTabsServiceConnected it returns true. Inside the callback onRelationshipValidationResult, the result is false. Therefore it's not validated

Did you have that issue ?