Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes race condition caused by billing client dereference #1388

Merged
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelogs

## 6.3.0
Refactors Google Play Java code limiting to a single billingClient. This can be considered a breaking change as it will fail when attempting to initialize the library more than once. It also adds documentation on the proper handling of the lifecycle [docs][docs/usage_instructions/connection_lifecyle.md]

## 6.2.4

[Feature]
Expand Down
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 30
def DEFAULT_BUILD_TOOLS_VERSION = "30.0.2"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 30
def DEFAULT_PLAY_SERVICES_VERSION = "17.6.0"

android {
compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)
Expand Down Expand Up @@ -59,6 +60,8 @@ repositories {
dependencies {
implementation 'com.facebook.react:react-native:+'
playImplementation 'com.android.billingclient:billing:3.0.3'
def playServicesVersion = safeExtGet('playServicesVersion', DEFAULT_PLAY_SERVICES_VERSION)
playImplementation "com.google.android.gms:play-services-base:$playServicesVersion"
amazonImplementation fileTree(dir: 'libs', include: ['*.jar'])

def supportLibVersion = safeExtGet('supportLibVersion', safeExtGet('supportVersion', null))
Expand Down
1 change: 1 addition & 0 deletions android/src/main/java/com/dooboolab/RNIap/DoobooUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DoobooUtils {
private static final String TAG = "DoobooUtils";
public static final String E_UNKNOWN = "E_UNKNOWN";
public static final String E_NOT_PREPARED = "E_NOT_PREPARED";
public static final String E_ALREADY_PREPARED = "E_ALREADY_PREPARED";
public static final String E_NOT_ENDED = "E_NOT_ENDED";
public static final String E_USER_CANCELLED = "E_USER_CANCELLED";
public static final String E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE";
Expand Down
24 changes: 10 additions & 14 deletions android/src/play/java/com/dooboolab/RNIap/PlayUtils.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package com.dooboolab.RNIap;

import static com.dooboolab.RNIap.DoobooUtils.E_ALREADY_OWNED;
import static com.dooboolab.RNIap.DoobooUtils.E_DEVELOPER_ERROR;
import static com.dooboolab.RNIap.DoobooUtils.E_ITEM_UNAVAILABLE;
import static com.dooboolab.RNIap.DoobooUtils.E_NETWORK_ERROR;
import static com.dooboolab.RNIap.DoobooUtils.E_SERVICE_ERROR;
import static com.dooboolab.RNIap.DoobooUtils.E_UNKNOWN;
import static com.dooboolab.RNIap.DoobooUtils.E_USER_CANCELLED;

import android.util.Log;
import com.android.billingclient.api.BillingClient;
import com.facebook.react.bridge.Promise;

public class PlayUtils {
private static final String TAG = "DoobooUtils";
public static final String E_UNKNOWN = "E_UNKNOWN";
public static final String E_NOT_PREPARED = "E_NOT_PREPARED";
public static final String E_NOT_ENDED = "E_NOT_ENDED";
public static final String E_USER_CANCELLED = "E_USER_CANCELLED";
public static final String E_ITEM_UNAVAILABLE = "E_ITEM_UNAVAILABLE";
public static final String E_NETWORK_ERROR = "E_NETWORK_ERROR";
public static final String E_SERVICE_ERROR = "E_SERVICE_ERROR";
public static final String E_ALREADY_OWNED = "E_ALREADY_OWNED";
public static final String E_REMOTE_ERROR = "E_REMOTE_ERROR";
public static final String E_USER_ERROR = "E_USER_ERROR";
public static final String E_DEVELOPER_ERROR = "E_DEVELOPER_ERROR";
public static final String E_BILLING_RESPONSE_JSON_PARSE_ERROR =
"E_BILLING_RESPONSE_JSON_PARSE_ERROR";
private static final String TAG = "PlayUtils";
public static final String E_PLAY_SERVICES_UNAVAILABLE = "E_PLAY_SERVICES_UNAVAILABLE";

private static PlayUtils instance = new PlayUtils();

Expand Down