Skip to content

SecurityException when binding to PostMessageService in TWA integrationΒ #526

@ehsan323

Description

@ehsan323

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions