GoogleChrome / GoogleChrome/android-browser-helper

SecurityException when binding to PostMessageService in TWA integration

Open
#526 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
832
Forks
370
Avg merge
1d 3h
Merged PRs (30d)
6

Description

Description:
I'm integrating a Trusted Web Activity (TWA) into my Android app and trying to enable postMessage communication. However, I'm encountering the following issue:

Crash Log:
java.lang.SecurityException: Not allowed to bind to service Intent { cmp=com.emofid.rnmofid/androidx.browser.customtabs.PostMessageService }

This happens after I added the following to my AndroidManifest.xml:



In my code, this line returns false and the postMessage connection never succeeds:
boolean result = mSession.requestPostMessageChannel(URL);

Dependencies Used:
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.browser:browser:1.7.0"
implementation "com.google.androidbrowserhelper:androidbrowserhelper:2.5.0"

Expected Behavior:
The call to requestPostMessageChannel() should return true, and the message channel should be established.

Actual Behavior:
The app crashes with a SecurityException related to PostMessageService, or requestPostMessageChannel() returns false when the service is not declared.

Steps to Reproduce:

Integrate TWA using the dependencies above.
Add PostMessageService to the manifest.
Attempt to call requestPostMessageChannel().

Additional Notes:

Digital Asset Links (DAL) verification is confirmed and working.
TWA launches correctly and shows content.
Issue occurs consistently when attempting to establish postMessage communication.

The TWA is created by BubbleCLI.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.