android-browser-helper
android-browser-helper copied to clipboard
DigitalGoodsApi clientAppUnavailable rejection on service
I trying to integrate DigitalGoodsApi. All works fine until the point when calling any service function from the getDigitalGoodsService callback.
window.getDigitalGoodsService('https://play.google.com/billing').then((service) => {
return service.getDetails(['test']);
})
This will throw DomException: clientAppUnavailable
service is however a proper instance of the goods API. Function getDetails, listPurchases and other's are available, but try to call any of them will throw the error.
Most of the source code bellow is generated directly from https://www.pwabuilder.com/.
Tried on Android API 24 and API 30 within emulator. Chrome version 110 on both API versions (So this should not require any origin trials anymore) CompileSDK Target is 33 (tried with 30 and 31 as well)
The counterpart delegation service is simple
public class DelegationService extends com.google.androidbrowserhelper.trusted.DelegationService {
@Override
public void onCreate() {
super.onCreate();
registerExtraCommandHandler(new DigitalGoodsRequestHandler(getApplicationContext()));
}
}
Gradle deps
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.androidbrowserhelper:billing:1.0.0-alpha09'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0'
}
Android Manifest contains
<service
android:name="DelegationService"
android:enabled="@bool/enableNotification"
android:exported="@bool/enableNotification">
<meta-data
android:name="android.support.customtabs.trusted.SMALL_ICON"
android:resource="@drawable/ic_notification_icon" />
<intent-filter>
<action android:name="android.support.customtabs.trusted.TRUSTED_WEB_ACTIVITY_SERVICE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
We're having this exact error too. We get it while logged into some Google accounts but not others. Did you find a fix @brainfoolong?
@monstermac77 No. Never had a working version of that. Ended up not using this API.
@monstermac77 No. Never had a working version of that. Ended up not using this API.
Got it. What API did you end up using? Since we’re in the Play Store I figured we had to use this API so Google got their 30% cut. Is there another option?
I guess it's not a topic for this issue. But in short: I know no alternative. In-App Payments in PWA in PlayStore is still a no-no today.
I guess it's not a topic for this issue. But in short: I know no alternative. In-App Payments in PWA in PlayStore is still a no-no today.
I assume you mean that it should work, but there's so little support that it's broken and Google doesn't care enough to fix it? It seems pretty austere to promote the use of PWAs, force us to use In-App billing, and then not support the API.
@brainfoolong Just wanted to follow-up on this since you seem to be the only active person discussing these issues.
We also have since been getting a lot of TypeError: Failed to construct 'PaymentRequest': required member details is undefined. Curious if you ran into that at all or have an idea of what the issue might be. The error is on var request = new PaymentRequest(paymentMethods); where paymentMethods is defined as:
const paymentMethods = [{
supportedMethods: ["https://play.google.com/billing"],
data: {
sku: sku,
},
}];
This is the full traceback
TypeError: Failed to construct 'PaymentRequest': required member details is undefined. purchase.js?new1:165
at makePurchase (purchase.js:163)
at HTMLDivElement.<anonymous> (purchase.js:293)
at HTMLDocument.dispatch (jquery.min.js:5)
at HTMLDocument.y.handle (jquery.min.js:5)
And purchase.js is: https://www.coursicle.com/all/pwa/js/purchase.js