facebook-android-sdk icon indicating copy to clipboard operation
facebook-android-sdk copied to clipboard

SDK 16.0.1 not working fully with Billing Client 5.0 - In-app purchase events are not sent.

Open grzegorzmalopolski opened this issue 1 year ago • 9 comments

Checklist before submitting a bug report

Java version

1.8

Android version

13

Android SDK version

33

Installation platform & version

Gradle plugin 7.4.x

Package

Other / I don't know

Goals

Upate billing client to 5.0 or 5.1 in Facebook SDK to send properly In-app purchase events to Meta analytics console.

Expected results

In our project we already use Google Billing Client with version 5.0. This billing client is suggested in Google Play developer console. (Should be always updated)

I want to use latest Facebook SDK with this client, but currently Facebook SDK use version 3.0.0 that can connect to Billing client in version 5.0 because of class missing.

We can't revert billing client to 4.0 because of already implemented migration from Billing client 4.0 to 5.0.

Actual results

In Facebool SDK Google client wrapper is missing class: com.android.billingclient.api.Purchase$PurchasesResult

This class exist in billing 3.x an 4.x but on billingclient.api.Purchase in 5.0 version this is changed. Because of that Facebook SDK can't create instance of InAppPurchaseBillingClientWrapper. When constructor create instance, try to find class by name com.android.billingclient.api.Purchase$PurchasesResult and this class is missing. So wrapper is created, but instance is null.

Result of that is that SDK can't query purchases and send it automatically as events to Facebook platform.

Steps to reproduce

Use Google billing client in version 5.0 and Facebook SDK in version 16.0.1 Make in-app purchase and see that no events are sent. No add to cart event and no purchase event.

Code samples & details

fun getOrCreateInstance(context: Context): InAppPurchaseBillingClientWrapper? {
      if (initialized.get()) {
        return instance
      }
      createInstance(context)
      initialized.set(true)
      return instance
    }




    private fun createInstance(context: Context) {
      val inAppPurchaseSkuDetailsWrapper = getOrCreateInstance() ?: return
      val billingClientClazz = getClass(CLASSNAME_BILLING_CLIENT)
      val purchaseClazz = getClass(CLASSNAME_PURCHASE)
      val purchaseResultClazz = getClass(CLASSNAME_PURCHASES_RESULT)
      val skuDetailsClazz = getClass(CLASSNAME_SKU_DETAILS)
      val purchaseHistoryRecordClazz = getClass(CLASSNAME_PURCHASE_HISTORY_RECORD)
      val skuDetailsResponseListenerClazz = getClass(CLASSNAME_SKU_DETAILS_RESPONSE_LISTENER)
      val purchaseHistoryResponseListenerClazz =
          getClass(CLASSNAME_PURCHASE_HISTORY_RESPONSE_LISTENER)
      if (billingClientClazz == null ||
          purchaseResultClazz == null ||
          purchaseClazz == null ||
          skuDetailsClazz == null ||
          skuDetailsResponseListenerClazz == null ||
          purchaseHistoryRecordClazz == null ||
          purchaseHistoryResponseListenerClazz == null) {
        return
      }
      val queryPurchasesMethod =
          getMethod(billingClientClazz, METHOD_QUERY_PURCHASES, String::class.java)
      val getPurchaseListMethod = getMethod(purchaseResultClazz, METHOD_GET_PURCHASE_LIST)
      val getOriginalJsonMethod = getMethod(purchaseClazz, METHOD_GET_ORIGINAL_JSON)
      val getOriginalJsonSkuMethod = getMethod(skuDetailsClazz, METHOD_GET_ORIGINAL_JSON)
      val getOriginalJsonPurchaseHistoryMethod =
          getMethod(purchaseHistoryRecordClazz, METHOD_GET_ORIGINAL_JSON)
      val querySkuDetailsAsyncMethod =
          getMethod(
              billingClientClazz,
              METHOD_QUERY_SKU_DETAILS_ASYNC,
              inAppPurchaseSkuDetailsWrapper.skuDetailsParamsClazz,
              skuDetailsResponseListenerClazz)
      val queryPurchaseHistoryAsyncMethod =
          getMethod(
              billingClientClazz,
              METHOD_QUERY_PURCHASE_HISTORY_ASYNC,
              String::class.java,
              purchaseHistoryResponseListenerClazz)
      if (queryPurchasesMethod == null ||
          getPurchaseListMethod == null ||
          getOriginalJsonMethod == null ||
          getOriginalJsonSkuMethod == null ||
          getOriginalJsonPurchaseHistoryMethod == null ||
          querySkuDetailsAsyncMethod == null ||
          queryPurchaseHistoryAsyncMethod == null) {
        return
      }



Missing class is 
    private const val CLASSNAME_PURCHASES_RESULT =
        "com.android.billingclient.api.Purchase\$PurchasesResult"

grzegorzmalopolski avatar Mar 29 '23 14:03 grzegorzmalopolski

Please update it

Fanketly avatar Sep 07 '23 13:09 Fanketly

we experience the same issue

daniel-moonactive avatar Oct 01 '23 15:10 daniel-moonactive

+1

dsanghan avatar Oct 06 '23 08:10 dsanghan

+1

airx avatar Oct 17 '23 03:10 airx

'com.facebook.android:facebook-android-sdk:16.2.0' 'com.android.billingclient:billing:6.0.1'

我在使用上面的版本SDK也是无法收到In-app purchase的事件记录,只能收到安装和启动的事件记录。

anoce avatar Nov 21 '23 02:11 anoce

me too implementation 'com.facebook.android:facebook-android-sdk:latest.release' implementation("com.android.billingclient:billing:6.0.1")

don't full work . no log iap event.

weijielv avatar Dec 06 '23 10:12 weijielv

'com.facebook.android:facebook-android-sdk:16.2.0' 'com.android.billingclient:billing:6.0.1'

我在使用上面的版本SDK也是无法收到In-app purchase的事件记录,只能收到安装和启动的事件记录。 所以请问,你最近解决这个问题了吗?求助

weijielv avatar Dec 06 '23 11:12 weijielv

'com.facebook.android:facebook-android-sdk:16.0.0' 
'com.android.billingclient:billing:6.1.0'

in-app-purchase event not triggered. other events(install, custom events) triggers.

When I researched in detail;

Google Play Billing Library version 3.0.0 appears in facebook-android-sdk. However, google has declared the following regarding the billing version.

  1. Starting on August 2, 2023, all new apps must use Billing Library version 5 or newer. By November 1, 2023, all updates to existing apps must use Billing Library version 5 or newer
  2. If your app is targeting Android 14 or higher, you must update to PBL 5.2.1 or PBL 6.0.1 or higher. So, active-updated apps use minimum v5. There are no more apps using v3.

How can facebook-android-sdk still use v3? How can it be so outdated?

abdulkadirgun avatar Dec 29 '23 10:12 abdulkadirgun

Same trouble - no purchase events. Is there any solution?

ilyasikirytski avatar Jan 29 '24 09:01 ilyasikirytski