android-browser-helper icon indicating copy to clipboard operation
android-browser-helper copied to clipboard

DigitalGoodsService not working after app installation, have to close the app and reopen to work

Open fabiel-leon-autofact opened this issue 9 months ago • 4 comments

Describe the bug After installation the DigitalGoodsService api is unavailable DigitalGoodsService error: OperationError: clientAppUnavailable clientAppUnavailable , i have to close the app and reopen to have access iam executing this code

 try {
     const e = await window.getDigitalGoodsService("https://play.google.com/billing");
     if (e) {
        const s = await e.listPurchases();
        console.log("Second verifications: ", s),
        this.result = !0
      }
     } catch (e) {
        console.error("DigitalGoodsService error:", e)
     }

To Reproduce Steps to reproduce the behavior:

  1. Install an app that List purchases on first render
  2. Open the app after installation and crash
  3. Close the app and reopen <<- IT WORKS
  4. uninstall and repeat from step 1

Expected behavior Digital goods api should work after installation

Did this ever used to work IDK, first time using twa.

Screenshots Image

Smartphone (please complete the following information):

  • Device: Pixel 8 Pro API 35 , and others phones
  • OS: Android 15
  • Browsers Installed Chrome
  • Browser Versions 133.0.6943.21
  • 'com.google.androidbrowserhelper:androidbrowserhelper:2.5.0' 'com.google.androidbrowserhelper:billing:1.0.0-alpha11'

Additional context Add any other context about the problem here.

fabiel-leon-autofact avatar Mar 24 '25 20:03 fabiel-leon-autofact

Hi @fabiel-leon-autofact - were you ever able to resolve this issue? We seem to have it on first install as well. (although in our case we’re calling getDetails()).


Some of our own findings:

  • Logcat includes this line:
05-08 11:00:17.789   512   512 W cr_DigitalGoods: Unable to execute getDetails.

This appears to be logged here: https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/browserservices/digitalgoods/DigitalGoodsAdapter.java;l=132-133;drc=467a8e68f685f9cfa47ee3fbfca20c22f7f6e893;bpv=0;bpt=0

  • PaymentRequest.show() still seems to work when this issue occurs.
  • asset-links appears to be set up correctly because the tab bar is not visible (and window.getDigitalGoodsService doesn't throw; only getDetails)

Right now we’re considering building our own fallback API on our backend that uses the Google Play Developer API to implement the same functionality as getDetails. Though that obviously doesn't work for listPurchases.

WFT avatar May 08 '25 19:05 WFT

hi , i was using this code to identify if the website is running inside the app, but it seems that is not intended for that, now im using a query parameter in the initial url when using the app and storing the result in sessionStorage , sessionStorage is keeped until you close the app and only the tab with the app keep the value, if you open the website in the browser it have his own sessionStorage and will not have that value

fabiel-leon-autofact avatar May 08 '25 19:05 fabiel-leon-autofact

Also running into this issue. We were fine until I started the upgrade to the new billing api and with that, the new billing helper (1.0.1 -> 1.1.0).

I'm now consistently getting W cr_DigitalGoods: Unable to execute getDetails, which doesn't go away even upon restarting the app. Downgrading to our original setup (billingclient:billing:6.1.0) works ok, so still investigating what's going on at all.

VesterDe avatar Jul 23 '25 10:07 VesterDe

@VesterDe FWIW we definitely had this issue pre 1.1.0. I'm pretty sure we observed it in 1.0.0-alpha11 too.

WFT avatar Jul 23 '25 18:07 WFT